开发者

htaccess URL rewrite: What am I messing up in the code?

I have the following rewrite rule:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} Catalog\/(string|page)\/
RewriteRule ^Catalog\/(string|page)\/([^\/]+)\/[^\.]+\.html$  Catalog/Catalog.php?$1=$2

RewriteRule is on one line but may be showing on multiple lines here.

My questions is mainly what am I doing wrong. I am not getting any errors so Rewrite is working. The address I am typing 开发者_JAVA技巧in to the browser is www.domain.com/Catalog/string/RT/Round_Tomato.html and what I was hoping to get is www.domain.com/Catalog/Catalog.php?string=RT

I am guessing my regex is messed up but have not been able to get it right.


I think that the first wrong thing is putting point without backslash before (.) => www.

 ^www\.([^/])/Catalog/([a-zA-Z0-9]+)/([a-zA-Z0-9_]+).html$ www.$1/Catalog/Catalog.php?string=$2

here is a clear example:

RewriteRule ^http://www.remotesite.com/(.*)$ /mirror/of/remotesite/$1

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

check this out:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^Catalog/(.+)/(.+)\.html$ /Catalog/Catalog.php?$1=$2

you should restart your apache server -if it's a local server- (start and stop) and you must be able to access http://localhost/Catalog/string/RT.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜