简体   繁体   中英

Mod Rewrite - Regular Expression equal sign in the URL

In my .htaccess i have a rewrite rules which reads values from a clean looking url.

I need to send all the ( vanity ) url to request.php except a URL with this path: /change-email/[number ( and or ) character and the '=' sign]

All work fine but when the string had a equal sign is intercepted from other rules.

Examples:

mysite.com/change-email/ --> go to request.php [ok]

mysite.com/change-email --> go to request.php [ok]

mysite.com/change-email/dasu564345ytfghafsfda --> go to change-email.php [ok]

mysite.com/change-email/dasu564345ytfghafsfda= -->go to request.php [not ok] it should go to /includes/change-email.php

is the 3° rule in main app section

this is the .htaccess

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#main app rules
RewriteRule ^change-email(\/|)?$ /request.php?key=change-email [QSA]
RewriteRule ^change-email/([\w+]{1,})(\/|)?$ /includes/change-email.php?email=$1 [QSA] <-- need to catch = sign!
RewriteRule ^([\w+]{1,})(\/|)?$ /request.php?&key=$1 [QSA]

ErrorDocument 404 /request.php

\w doesn't consider = . Try following regex for change-email.php url:

^change-email/([\w\=]{1,})(\/|)?$

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