Mod Rewrite:重写但未找到的链接

时间:2012-11-11 00:03:42

标签: apache .htaccess url mod-rewrite typo3

我正在尝试在WAMP系统上使用TYPO3,但我遇到了重写URL的问题。 我已经安装了包含“入门”网站的介绍包。每次我尝试通过以下方式之一访问网站: 本地主机/ TYPO3 本地主机/ TYPO3 / index.php的 本地主机/ TYPO3 / index.php文件/ GET-开始

网址变为localhost / typo3 / get-started

哪个没关系,这意味着mod_rewrite已开启并正常工作。问题是我看不到网站localhost / typo3 / get-started,而是我找到了一个“找不到对象”页面。

我在Symfony 1.4的同一台机器上遇到同样的问题,但我从不关心这一点,因为在Symfony上我可以使用frontend_dev.php页面访问该站点(在我的生产环境中,重写的URL工作正常)。

这是TYPO3目录的httpd.conf条目:

Alias /typo3 "C:\workspace\typo3"
<Directory "C:\workspace\typo3">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

这是.htaccess文件(已经在TYPO3包中,我没有修改过),我删除了非相关部分

### Begin: Settings for mod_rewrite ###

# You need rewriting, if you use a URL-Rewriting extension (RealURL, CoolUri, SimulateStatic).

<IfModule mod_rewrite.c>

# Enable URL rewriting
RewriteEngine On

# Change this path, if your TYPO3 installation is located in a subdirectory of the website root.
#RewriteBase /

# Rule for versioned static files, configured through:
# - $TYPO3_CONF_VARS['BE']['versionNumberInFilename']
# - $TYPO3_CONF_VARS['FE']['versionNumberInFilename']
# IMPORTANT: This rule has to be the very first RewriteCond in order to work!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

# Stop rewrite processing, if we are in the typo3/ directory.
# For httpd.conf, use this line instead of the next one:
# RewriteRule ^/TYPO3root/(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]

# Redirect http://example.com/typo3 to http://example.com/typo3/index_re.php and stop the rewrite processing.
# For httpd.conf, use this line instead of the next one:
# RewriteRule ^/TYPO3root/typo3$ /TYPO3root/typo3/index.php [L]
RewriteRule ^typo3$ typo3/index_re.php [L]

# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# Main URL rewriting.
# For httpd.conf, use this line instead of the next one:
# RewriteRule .* /TYPO3root/index.php [L]
RewriteRule .* index.php [L]

</IfModule>

### End: Settings for mod_rewrite ###

2 个答案:

答案 0 :(得分:2)

解决了,问题出在easyphp设置上,因为我没有使用它的DocumentRoot(只是使用别名),将DocumentRoot更改为我保持项目解决它的那个

答案 1 :(得分:1)

您应该按照#RewriteBase /文件中的说明将RewriteBase /typo3/更改为.htaccess