开发者

mod_rewrite not working consistently

开发者 https://www.devze.com 2022-12-12 22:49 出处:网络
I\'ve got a rewriting scheme going on that was working fine. Basically, anything in the url is passed as a querystring to index.php, so /dave/bob is rewritten to /index.php?page=dave/bob. I deal with

I've got a rewriting scheme going on that was working fine. Basically, anything in the url is passed as a querystring to index.php, so /dave/bob is rewritten to /index.php?page=dave/bob. I deal with the parsing of this in index.php. Here's my .htaccess:

R开发者_StackOverflow中文版ewriteEngine on
RewriteRule ^([^\.]+)?$ index.php?page=$1 [L]

The problem I'm having is that sometimes the url is displaying incorrectly in the address bar. See these two examples: working and not working. The same problem occurs with the services page. For those of you who'd rather not visit external links, goldseal.skilldrick.co.uk/contact is displaying as goldseal.skilldrick.co.uk/contact/?page=contact in the address bar.

As you'll see, I'm currently working in a subdomain, which is being redirected to a directory under /public_html, using cpanel. Might this be the cause?


Try putting a "/" in front of index.php.


Ok, I'm an idiot, but I've worked it out!

The reason services and contact were both causing problems was because I already had dirs under public_html/goldseal called /services and /contact (from a previous incarnation of the site), so the rewrite rule was getting confused when I told it to go to /contact.

Thanks for all your help, and sorry for wasting your time :P

0

精彩评论

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