logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Mod rewrite not works with existing directory
Author
Camo



Joined: 05 Mar 2013
Posts: 10
Location: SK

PostPosted: Thu 14 Mar '13 14:29    Post subject: Mod rewrite not works with existing directory Reply with quote

Hi,
Can you explain me why my rules don´t work as I want?
I want to make hiden rewrite from url like host.sk/dir/dir2 to www.host.sk/dir/index.php?url=dir2

Everithing works fine, only if that dir2 is real directory it redirects me to www.host.sk/dir/dir2/?url=dir2.
If I add there something like host.sk/dir/dir2/something
it wokrs fine and makes hidden rewrite to www.host.sk/dir/index.php?url=dir2/anything
Why this address dir/dir2 doesn´t work? Can you give me some link which explain it?
You can see that proces in Opera dragonfly on badLink / goodLink
Here is my .htaccess:
Code:

Options +FollowSymlinks

RewriteEngine on

RewriteBase /myCMS

RewriteCond %{REQUEST_FILENAME} !-f

#RewriteCond %{REQUEST_FILENAME} !-d

#add www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*)$ http://www.%{HTTP_HOST}/myCMS/$1 [R=301,L]

#remove / from the end
RewriteRule ^(.+)/$ $1 [R=301,L]

#hidden rewrite to ?url=var
#RewriteCond%{QUERY_STRING} !url
RewriteRule (.*)$ index.php?url=$1 [L,QSA]

Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 21 Mar '13 11:35    Post subject: Reply with quote

You have to exclude the index.php in dir else it starts to loop.
Back to top
Camo



Joined: 05 Mar 2013
Posts: 10
Location: SK

PostPosted: Thu 21 Mar '13 18:24    Post subject: Reply with quote

How do you mean it?

PS: Few days ago one good man advised me to switch off "DirectorySlash Off" direction. And it works. Sorry that I didn´t send the note about it.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 21 Mar '13 18:59    Post subject: Reply with quote

You rewrite against index.php in /myCMS, so you have to exclude that file within your rewrite rules

something like

RewriteRule ^index\.php - [L]
Back to top
Camo



Joined: 05 Mar 2013
Posts: 10
Location: SK

PostPosted: Thu 21 Mar '13 20:23    Post subject: Reply with quote

It seems it doesn´t work. I past it before that hidden rewrite, also before whole rules, but without any efect.
Something similar I tryed to achieve with that QUERY_STRING test.

Thanks!
Back to top


Reply to topic   Topic: Mod rewrite not works with existing directory View previous topic :: View next topic
Post new topic   Forum Index -> Apache