简体   繁体   中英

Rewrite an url with htaccess

I would rewrite an url

http://mydomain/index.php?s=profil

to

http://localhost/profil

I have try this in my .htaccess:

RewriteRule ^([^/]*)$ /index.php?s=$1 [L]

But not work (error 500).

Enable mod_rewrite before the RewriteRule:

RewriteEngine On

I guess you wanted your url http://urdomain.com/profile to show content from http://urdomain.com/index.php?s=profil , an example of how you do it is this:

RewriteEngine On
RewriteBase /
RewriteRule    ^content/([A-Za-z0-9-]+)/?$    index.php?s=$1    [NC,L]

This rule will redirect your page urdomain.com/content/Alphanumeric123 to index.php?s = $1

Explaination:

[a-z] - lower case characters
[A-Z] - Upper case characters
[0-9] - numbers

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