简体   繁体   中英

Mod_Rewrite on but doesn't change URL Layout

Hello I've got a problem with rewriting my URLs via .htaccess

Php Info: Server API CGI/FastCGI Hoster settings: Apache mod_rewrite ON

Current url Layout:

http://www.xxxx.at/beitrag.php?thema=Bitcoins%20fuer%20jedermann%20gratis

Wanted:

http://www.xxxx.at/beitrag/Bitcoins%20fuer%20jedermann%20gratis (can I change %20 to "-" maybe too?)

I've stup a .htacces which looks like:

RewriteEngine On
RewriteRule (.*)_(.*)\.html$ /bitcoins.php?to=$1 [qsappend,L]

But the URL still looks the same, there is nothing changed.

Can someone help me please? regards

Try:

Options -Multiviews
RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+beitrag\.php\?thema=([^&\ ]+)
RewriteRule ^ /beitrag/%1 [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bietrag/(.+)$ /bietrag.php?thema=$1 [L]
  1. Turn off Multiviews so that /beitrag doesn't preemptively get served with /beitrag.php
  2. The first rule matches the HTTP request line, gruops the query string, and redirects the browser so that the new URL shows up in the location bar
  3. The second rule matches the new URL and internally rewrites it back to the one with the query string.

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