I'm using a code snippet from the Invision Power Board forum software on my own site to, sort of, connect the two. I have a "member bar" that I wanna put on every page in my website that has a login link, profile link, etc. I've already done this, the only problem is that on the pages I want to implement it on, I have to put a ? after the ".php". So I need a mod_rewrite condition that turns

http://www.mysite.com/index.php into http://www.mysite.com/index.php?

http://www.mysite.com/html/about.php into http://www.mysite.com/html/about.php?

I know this is probably very simple, but I've tried to learn regular expressions and it gives me a headache every time I try haha.

Also, an aside question: for the index page, instead of doing http://www.mysite.com/index.php?, would http://www.mysite.com/? work as well?

Recommended Answers

All 3 Replies

Out of curiousity, why does it need a blank "?", or are there goodies after that?

I ask because if there are GET variables after the ?, the rewrite could really mess stuff up by putting additional "?" into the URL.

Im adapting this from a lighttpd config, but I think this should be close.

RewriteRule ^[$/]$    /index.php?
RewriteRule ^/(.*)$    /$1?
RewriteRule ^/([^\?]*)\?(.*)$    /$1?$2

First line will take 'yoursite.com' or 'yoursite.com/' and turn into 'yoursite.com/index.php?'.

Second line takes anything and appends a '?' to it.

Third line is a better version of the second, but I'm not sure if you need it, or if it even works the way I meant. The idea is, if your scripts are using GET variables, we make sure that the final URL has only 1 "?" in it.

I'm actually not sure why it needs the question mark (?) at the end, when I didn't include it, I kept getting a blank page with the message "No input file specified."

the error message implies a bug in the code snippet, you are using, it is often simpler/safer (for the reasons outlide by petzoldt01) to modify the login code to accomodate a blank uri, than allow bugs to go forward.
post the scrap?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.