开发者

HTACCESS | Social Engine | Stop redirecting Root index

开发者 https://www.devze.com 2023-01-28 02:55 出处:网络
I have a install of SocialEngine currently and all urls are processed by .htaccess file that redirects through to the socialengine.php file and processes nice URLs etc.

I have a install of SocialEngine currently and all urls are processed by .htaccess file that redirects through to the socialengine.php file and processes nice URLs etc.

I am wanting to stop example.com/ been redirected through to the script as I am wanting to put a different index page there. So I want my .htaccess file to process every other file it cant find through the socialengine.php s开发者_开发技巧cript but keep the root file going to index.php.

So if it’s .com/ it goes to index.php and if it’s anything else it’s processed through the socialengine.php.

Below is my .htaccess file that requires alteration.

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /socialengine\.php
  RewriteRule (.*) socialengine.php?rewrite=2 [L,QSA]
  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$

  RewriteRule (.*) socialengine.php?rewrite=1 [L,QSA]
  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ socialengine.php?rewrite=1 [L,QSA]
</IfModule>

Thanks in advance for any replies.


Put the code below straight after RewriteEngine On.

RewriteCond %{REQUEST_URI} ^/$
RewriteRule .* - [L]

Explanation: The first line matches a request to http://example.com/ (REQUEST_URI contains / in this case). The second line passes the request untouched (note the -)

References:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号