i know this question has been asked/answered several times already, but i just cant seem to get past it. so, my apologies...
while in the site dev phase, i want the browsers address bar to display: domain.com/dev/item
i would like the RewriteRule to change it to: domain.com/dev/index.php?p=item
im using the .htaccess located in the public_html directory for this. the .htaccess within public_html/dev, which works fine, is configured to开发者_运维知识库 redirect everybody who is not using my ip to domain.com. my apache version is 2.2.15 and i've confirmed that i am able to redirect using .htaccess, but the top level .htacess simply doesnt work. here is the code im using:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^dev/(.*)$ dev/index.php?p=$1 [NC]
#variations tried: ^dev/(.*)+$, ^dev/(.*)+?$
the, including variations, results in a 404, /dev/item not found. removing the dev/ from ^dev/(.*)$ results in the correct url format, but the following server variables:
[REDIRECT_QUERY_STRING] => p=
[REDIRECT_URL] => /404.shtml
[QUERY_STRING] => p=
[REQUEST_URI] => /dev/item
my goal is to make a small change to support this type of rewrite for both the live site and the dev copy. but i just cant understand what im doing wrong. i really would appreciate any help.
You need to specify the / at the beginning of the rewrite paths.
Try this instead:
RewriteEngine on
RewriteBase /
# If request is for a file that does actually exist, don't rewrite.
RewriteCond %{REQUEST_FILENAME} !-f
# If request is for a directory that does actually exist, don't rewrite.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/dev/(.*)$ /dev/index.php?p=$1 [NC]
精彩评论