简体   繁体   中英

.htaccess file not redirecting - guidance wanted

I have this url:

<a href="drive_to_london/?procid=12">details</a>

the url becomes in addressbar:

http://web228.sydney.webhoster.ag/soputnik/drive_to_london/?procid=12

but I want to process the logic in details.php .

How can I process the data in details.php in background and keep the first url in the address?

I tried this:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^drive_to_(.*)$   http://web228.sydney.webhoster.ag/soputnik/details.php [R=301,L]

but it is not working, error is: NOT FOUND

please help

If you don't want the URL to change, then it's not a redirect, just a rewrite.

Change:

RewriteRule ^/test/drive_to_(.*)$   /test/details.php [R=301,L]

To something like:

RewriteRule ^/test/drive_to_(.*)$   /test/details.php?city=$1 [L]

Substitute your code with this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^test/drive_to_(.*?)/?$ /test/details.php [L,NC]
  1. dont forget to pass any url params to details.php.

    Rewriterule ^/drive_for_(.*)/\\?(.*)$ http://domain.de/test/details.php/?$1 [R=301,L]

  2. it seems relevant that you want to pass the city name as well, otherwise that context gets lost in the rewrite. If that is another url param you could pass it through to details.php as such

    Rewriterule ^/drive_for_(.*)/\\?(.*)$ http://domain.de/test/details.php/?$2&city=$1 [R=301,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