简体   繁体   中英

How to get URL Parameters after changing htaccess to clean URLs?

I have URL Rewriting Activated:

Options +FollowSymLinks

RewriteEngine On

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

RewriteRule ^publisher/([^/\.]+)/?$ /publisher.php?page=$1 [QSA]

I want to take the parameters from this URL via $ _GET:

https://website.com/publisher/2/

When I do the following...

$id = $_GET["page"];

echo "ID:". $id;

... My results stay empty and there is no output

I tried the following steps, other community members already recommended:

Getting mod_rewrite to pass $_GET params?

Why can not I get on here? Thanks in advance.

UPDATE: After adding

Options -MultiViews

it works fine but now I have anothe problem: Everytime I go to another page via a link I get a 300: Multiple Options. https://website.com/test/ --> 300: /test.php/

Problem solved:

Put this at your FIRST line and before other options:

Options -MultiViews

This rewrite condition changes only the url not the data. Remove ?php=$1 because this is only url not a real get data.

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