Apache htaccess在ubuntu中不工作
你好,几个月前,我开始了一个网站项目,经过几周的工作,昨晚我继续在我的windows pc上开发,一切都很好。 今天我将它移植到Ubuntu12.04LTS,在启动apache/mysql之后,我尝试访问一些网站URL。(使用vhost设置,如:tms.localhost/path…) 我面临的问题是,我不知道为什么干净的URL和mod_重写似乎不起作用。不再调用我的自定义php重定向页面加载脚本(index.php) 这是自第1天起保持不变的htaccess。需要指出的是,只有当我像这样输入vhost url时,这才有效http://tms.localhost/如果在此之后添加任何内容,我将获得默认的apache 404页面Apache htaccess在ubuntu中不工作,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,你好,几个月前,我开始了一个网站项目,经过几周的工作,昨晚我继续在我的windows pc上开发,一切都很好。 今天我将它移植到Ubuntu12.04LTS,在启动apache/mysql之后,我尝试访问一些网站URL。(使用vhost设置,如:tms.localhost/path…) 我面临的问题是,我不知道为什么干净的URL和mod_重写似乎不起作用。不再调用我的自定义php重定向页面加载脚本(index.php) 这是自第1天起保持不变的htaccess。需要指出的是,只有当我像这样输入v
#Debugging - Error reporting
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
#Commpression
<ifmodule mod_deflate.c="">
<filesmatch ".(js|css|html|png|jpg|jpeg|swf|bmp|gif|tiff|ico|eot|svg|ttf|woff|pdf)$"="">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>
Options All -Indexes +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# remove spaces from start or after /
#RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L,R=301,NE]
# remove spaces from end or before /
#RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L,R=301,NE]
# replace spaces by - in between
#RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1+$2 [L,R=301,NE]
# Remove trailing slash
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [L,R=301]
# Add trailing slash
#RewriteCond %{REQUEST_URI} !(/$|\.)
#RewriteRule (.*) %{REQUEST_URI}/ [L,R=301]
# Remove multiple slashes
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/{2,} [NC]
RewriteRule ^(.*) $1 [R=301,L]
# Clean url rewrite
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*\.(png|jpg|jpeg|bmp|gif|css|js|json)$ [NC]
#RewriteRule ^([^/]+/?.+)$ /index.php?req=$1 [L,QSA]
#RewriteRule ^(.*)$ /index.php?req=$1 [L,QSA]
RewriteRule ^(.*)$ /index.php [L,QSA]
</IfModule>
# Big thnx to anubhava for his regex help - linkedin.com/in/anubhava
嗯,没什么问题。
显然是压缩程序或谷歌驱动器(我将项目重命名为
.htaccess
至htaccess
。您是否确保启用了mod_rewrite?此.htaccess文件的位置是什么?htaccess位于根目录,index.php是。mod_rewrite是启用的。请检查更新后thnx:)那么.htaccess和index.php都被放在/var/www/tms
路径中了吗?什么是不适合您的完整URL示例?
<VirtualHost *:80>
ServerAdmin webmaster@tms.localhost
DocumentRoot /var/www/tms
ServerName tms.localhost
#ServerAlias www.example.com
</VirtualHost>
core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status