fritzmg / contao-short-urls
1.3.8
2023-06-01 16:55 UTC
Requires
- php: >=5.2
- contao-community-alliance/composer-plugin: ~2.4 || ~3.0
- contao/core-bundle: ~3.1 || ~4.3
Conflicts
- terminal42/header-replay-bundle: >=1.4.0,<=1.4.2
Replaces
- contao-legacy/short_urls: 1.3.8
README
已弃用,请使用terminal42/contao-url-rewrite代替。
Contao 短网址
简单扩展,提供“短网址”,即重定向到具有更长URL的现有资源。例如,您可以创建如下重定向:
example.org/foo
»http://www.example.org/lorem/ipsum/dolor.html
example.org/123pdf
»http://www.example.org/files/lorem/ipsum/dolor.pdf
example.org/abcd
»http://www.some-other-website.com/foo.html
而无需编辑.htaccess
文件(以插入这些重定向作为 Redirect, RedirectMatch 或 RewriteRule 指令)或更改服务器配置。这些重定向可以在后台的内容下的短网址下创建。
要求
您需要编辑Contao 3的默认.htaccess
文件,并更改它,就像您在使用不带.html
后缀的URL一样。即您必须更改以下行:
RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|gz)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*\.html$ index.php [L]
到
RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|gz)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
这样,任何请求(不指向文件或目录)都将由Contao处理。
Contao 4
对于Contao 4,无需更改.htaccess
。您还需要要求此扩展至少为版本^1.3.3
。