简体   繁体   中英

htaccess RewriteCond for RewriteRule everything except of

I need to set up the following scenario:

I need to get URLs like /Login or /Start to be redirected to core.php?fn=Login or core.php?fn=Start

But whenever I enter smth like /profile_id I want it to be redirected to profile.php?profile_id=profile_id

RewriteRule ^(.*)$ /core.php?fn=$1 Bit it throws out an 500 error.

How can i set up that one?

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

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

RewriteRule ^(Login|Start)/?$ core.php?fn=$1 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ profile.php?profile_id=$1 [L,QSA,NC]

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