Forum Moderators: phranque
I'm in a bit of a trouble here, so I'll cut right to the chase.
I currently have a couple of pages located at:
example.com/index.php?network=page1
example.com/index.php?network=page2
example.com/index.php?network=page3
etc.
I want to be able to change that to:
example.com/page1/
example.com/page2/
example.com/page3/
I have successfully done that by adding this to my htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ index.php?network=$1
RewriteRule ^([a-zA-Z0-9\_\-]+)$ index.php?network=$1
-----
Problem:
If I try to visit an actual sub-directory from the website via the main page, lets say the forums, it will will do the following: it will go to
access example.com/forums it will go to example.com/forums/?network=forums
access example.com/forums/ it will stay on the index.php page and not go to the forums
-----
How can I only make the rewrite work with my "index.php?network=" pages, and not actual sub-directories on my website?
Please help me for a solution with this.
[edited by: Evolve123 at 10:01 pm (utc) on Aug. 22, 2008]
Your rule says, "Rewrite any URL that is in the top-level directory, including those that end with a slash, except for index.php." So, you rule will happily rewrite robots.txt, and all of your image and CSS files to the index.php file.
The four basic methods are:
Of these, the first three are by far the most efficient. You will have to pick one based on your current site URLs, and those you may plan to use in the future. You can mix-and-match features of all of them. It is especially important to only do the file- and directory-exists checks when absolutely necessary; Otherwise you can seriously bog down your server with all those filesystem requests.
Jim
[edited by: jdMorgan at 10:15 pm (utc) on Aug. 22, 2008]