I have the following .htaccess rule:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\/* index\.php?slug=$1
The main idea is to capture links and send them to a dispatcher which, if certain RegEx rules apply, calls a php file. Everything is sent to index.php, which does the RegEx comparison. @CBroe, I try to match a URL pattern, and then select the correct php to call, according to an array of 'rules'=>'scripts'. See below.
Added: @iainn, it's an ages old system inspired in WordPress' "pretty URLs". I can't simply rewrite it all at the moment, I'm not allowed to allocate office time for that.
Eg:
$nodes = array(
'/posts\/(?P<slug>.+)(\/*)$/'=>'posts.php',
'/home(\/*)$/'=>'home.php',
)
It's been alright until Facebook started adding the?fcbid querystring at the end of the URLs. Added: @CBroe, now it just fails matching rules, because they don't expect a querystring.
Added: as @Adam S. suggested, some examples that work:
http://something.com/posts/1589285645-title-of-a-post
http://something.com/posts/1589285645-title-of-a-post/
http://something.com/home
http://something.com/home/
And the following don't work
http://something.com/posts/1589285645-title-of-a-post?fbclid=whatever
http://something.com/posts/1589285645-title-of-a-post/?fbclid=whatever
http://something.com/home?fbclid=whatever
http://something.com/home/?fbclid=whatever
I've already tried several posts here with suggestions on dealing with this, but none of these apply to my setup.
How should I reformat my .htaccess file to accomplish this?
Thanks!
You may try this rule:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?slug=$1 [L,QSA]
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.