简体   繁体   English

htaccess RewriteCond for RewriteRule除了

[英]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 我需要将/ Login或/ Start之类的URL重定向到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 但是每当我输入类似/profile_id smth时,我都希望将其重定向到profile.php?profile_id=profile_id

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

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: 通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在DOCUMENT_ROOT目录下的.htaccess

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM