简体   繁体   中英

Apache rewrite rule is getting ignored while other functions are working properly

I have LAMP server running on Ubuntu 14.04, and everything seems to be configured fine. The Only problem that am having is that, the rewrite rule is somehow getting ignored without issuing any error. The page reloads again as usual after modifying the .htaccess file. What I am trying to do, is to route all traffic to index.php using the following code:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

Other rules are functioning properly, eg. if I add deny from all and reload the page,I immediately get en error. All files and folders are located in the /var/www/ root directory. I don't know what am missing here, I spent hours debugging this issue without a solution :(.

The . will only match a single character. Try using .* to match anything.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php [L]

I found a solution to redirect all traffic to index.php by pointing the document root to index.php:

<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/index.php
</VirtualHost>

thanks @Chris for the help.

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