【发布时间】:2022-01-25 09:58:35
【问题描述】:
目前我有我的 laravel 项目的暂存链接
http://**.***.**.***/project-name/cart
如果项目像这样访问http://**.***.**.***/project-name/cart
它是可访问的,但如果你像这样访问它
http://**.***.**.***/project-name/cart/
当购物车后面有斜线时,它会重定向到http://**.***.**.***/cart
导致找不到
这和Htaccess有关吗?
顺便说一句,这是我的 htaccess 代码
#<IfModule mod_deflate.c>
# # Compress HTML, CSS, JavaScript, Text, XML and fonts
# AddOutputFilterByType DEFLATE application/javascript
# AddOutputFilterByType DEFLATE application/rss+xml
# AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
# AddOutputFilterByType DEFLATE application/x-font
# AddOutputFilterByType DEFLATE application/x-font-opentype
# AddOutputFilterByType DEFLATE application/x-font-otf
# AddOutputFilterByType DEFLATE application/x-font-truetype
# AddOutputFilterByType DEFLATE application/x-font-ttf
# AddOutputFilterByType DEFLATE application/x-javascript
# AddOutputFilterByType DEFLATE application/xhtml+xml
# AddOutputFilterByType DEFLATE application/xml
# AddOutputFilterByType DEFLATE font/opentype
# AddOutputFilterByType DEFLATE font/otf
# AddOutputFilterByType DEFLATE font/ttf
# AddOutputFilterByType DEFLATE image/svg+xml
# AddOutputFilterByType DEFLATE image/x-icon
# AddOutputFilterByType DEFLATE text/css
# AddOutputFilterByType DEFLATE text/html
# AddOutputFilterByType DEFLATE text/javascript
# AddOutputFilterByType DEFLATE text/plain
# AddOutputFilterByType DEFLATE text/xml
#
# # Remove browser bugs (only needed for really old browsers)
# BrowserMatch ^Mozilla/4 gzip-only-text/html
# BrowserMatch ^Mozilla/4\.0[678] no-gzip
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Header append Vary User-Agent
#</IfModule>
#
### EXPIRES CACHING ##
#<IfModule mod_expires.c>
# ExpiresActive On
#
# # Images
# ExpiresByType image/jpeg "access plus 1 year"
# ExpiresByType image/gif "access plus 1 year"
# ExpiresByType image/png "access plus 1 year"
# ExpiresByType image/webp "access plus 1 year"
# ExpiresByType image/svg+xml "access plus 1 year"
# ExpiresByType image/x-icon "access plus 1 year"
#
# # Video
# ExpiresByType video/mp4 "access plus 1 year"
# ExpiresByType video/mpeg "access plus 1 year"
#
# # CSS, JavaScript
# ExpiresByType text/css "access plus 1 month"
# ExpiresByType text/javascript "access plus 1 month"
# ExpiresByType application/javascript "access plus 1 month"
#
# # Others
# ExpiresByType application/pdf "access plus 1 month"
# ExpiresByType application/x-shockwave-flash "access plus 1 month"
#</IfModule>
### EXPIRES CACHING ##
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# # Force Https
# RewriteEngine On
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# # Force www
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Check if mod is installed. If not, you can try to comment the condition
<IfModule mod_php7.c>
php_value post_max_size 200M
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
<FilesMatch "^\.">
Order allow,deny
Deny from all
</FilesMatch>
【问题讨论】:
-
您的
.htaccess文件在哪里?
标签: php laravel apache .htaccess mod-rewrite