简体   繁体   中英

htaccess url variable issues

So I'm having a small issue.

I have my index.php page as a base page for all of my pages data stored in the database. I'm using this htaccess to rewrite all of my pages, excluding posts from the blog.

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

#ALL STANDARD PAGES
RewriteRule (.*) index.php [QSA,NC,L]

#TRIED ALL THESE, NO LUCK
#RewriteRule (.*) index.php?%{QUERY_STRING} [L]
#RewriteRule ^.+$ /index.php [L]
#RewriteRule ^((?!index\.php).+)$ /index.php [L]

#ALL SPECIAL POSTING PAGES
RewriteRule    ^/posts/([0-9]+)/?$    view_post.php?id=$1    [NC,L]

This works perfectly for any page I have without variables on the url.

Example:

www.mysite.com/home | | www.mysite.com/contact

All of these load perfectly. But if I add any variables the page crashes for a 404.

Example:

www.mysite.com/contact?email=sent

I'm not really sure what to do, I've tried searching for guides online to teach me the proper syntax, googling if others have had the same issues, so far nothing has brought any luck.

Please help.

Try this, please comment out previous cond for checking i am assuming you are rewriting these requests www.mysite.com/contact to index.php page.

RewriteEngine on
RewriteCond %{THE_REQUEST} ^(.*)$
RewriteRule ^ index.php [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM