hankknight
asked on
RewriteRule with NOTHING on the end of URL
Hello,
I would like:
http://www.mysite.com/foobar
to be re-written as:
http://www.mysite.com/index.php?page=foobar
This works ONLY if zz is at the end:
RewriteRule ^(.*)zz index.php?page=$1 [NE]
This does NOT work:
RewriteRule ^(.*) index.php?page=$1 [NE]
Any ideas?
Thanks!
I would like:
http://www.mysite.com/foobar
to be re-written as:
http://www.mysite.com/index.php?page=foobar
This works ONLY if zz is at the end:
RewriteRule ^(.*)zz index.php?page=$1 [NE]
This does NOT work:
RewriteRule ^(.*) index.php?page=$1 [NE]
Any ideas?
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
Neither of these work:
RewriteRule ^(.*)$ index.php?page=$1 [NE]
or
RewriteRule ^(.*)$ index.php?page=$1 [NE,L]
They both seem to redirect to:
index.php?page=index.php
regardless of what the url is.
Also, thanks ravenpl for pointing out the NE and loop detection issues.
Neither of these work:
RewriteRule ^(.*)$ index.php?page=$1 [NE]
or
RewriteRule ^(.*)$ index.php?page=$1 [NE,L]
They both seem to redirect to:
index.php?page=index.php
regardless of what the url is.
Also, thanks ravenpl for pointing out the NE and loop detection issues.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where do you have the directives? In your httpd.conf file, or in you .htaccess file?
hankknight: You haven't use my advice, have You? Not that I added one more line, and modified the original...
If your making your pages search engine freindly then the best way is to fool them into thinking the page is not dynamic (PHP Driven) by giving it a HTM extension so that it thinks it is a static HTMl page.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.htm$ index.php?page=$1 [L]
For example
http://www.mydomain.com/foobar.htm
will call the PHP script index.php?page=foobar and the URL will still appear as if they are looking at foobar.htm.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.htm$ index.php?page=$1 [L]
For example
http://www.mydomain.com/foobar.htm
will call the PHP script index.php?page=foobar and the URL will still appear as if they are looking at foobar.htm.
ASKER
Thanks,
This seems to work best for me.
RewriteEngine on
RewriteCond $1 !=admin/
RewriteRule ^([^.]+)$ index.php?page=$1 [L]
I have posted a related question here:
https://www.experts-exchange.com/questions/22064358/rewrite-causing-problems.html
This seems to work best for me.
RewriteEngine on
RewriteCond $1 !=admin/
RewriteRule ^([^.]+)$ index.php?page=$1 [L]
I have posted a related question here:
https://www.experts-exchange.com/questions/22064358/rewrite-causing-problems.html
I don't understand why it's working for You, but whatever...
ASKER
->> I don't understand why it's working for you
Thanks for asking.
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^/(.*)$ /index.php?page=$1 [NE,L
This does NOT prevent things like:
info.php
from being re-written.
But this:
RewriteRule ^([^.]+)$ index.php?page=$1 [L]
does not re-write ANYTHING that has a . in it.
That is why.
Thanks for asking.
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^/(.*)$ /index.php?page=$1 [NE,L
This does NOT prevent things like:
info.php
from being re-written.
But this:
RewriteRule ^([^.]+)$ index.php?page=$1 [L]
does not re-write ANYTHING that has a . in it.
That is why.
RewriteRule ^(.*)$ index.php?page=$1 [NE]