开发者

htaccess redirect to a folder

I wasn't sure what the title should be but its s simple concept but I'm useless with .htaccess rewrites.

I currently have:

RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1

which will happily send all requests to my index and I can do what I want.

I have:

RewriteRule ^events/([a-zA-Z0-9-./]+)/?$ index.php?page=events/index&id=$1

For more i开发者_开发问答ntermit stuff..

But I want to say

If the url is "/mycms/..." Send use to %{HTTP_HOST}/cms and stay there...

Can anyone help? my 'catch all' rule keeps fecking it up.


Edit I Got this to work wonderful

RewriteRule ^mycms([a-zA-Z0-9-./]+)?$ /cms$1 [L]

RewriteCond %{REQUEST_URI} !^/cms 
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1

Now I write http://localhost/mycms and will head off to http://localhost/cms

I still want to mask the '/cms/' folder though... o_O


You just need to place a rewrite before your catch all and use the L flag to prevent it being rewritten again, something like this should suffice.

RewriteRule ^events/([a-zA-Z0-9-./]+)/?$ index.php?page=events/index&id=$1 [L]
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜