我有一個Joomla組件「com_foo」時,通過所謂的正常工作......的Joomla URL重寫的組件,而不重定向
http://my.joomla.site/index.php?option=com_foo&id=1234
...但我需要的URL採用以下格式:
http://my.joomla.site/getfoo/1234
我能得到最接近的是具有以下的.htaccess重寫這導致重定向:
RewriteEngine On
# My Rule
RewriteRule ^getfoo/(.*)$ /index.php?option=com_foo&id=$1 [R=301,L]
# Joomla rules
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
我似乎無法弄清楚如何使相同的事情「內部」工作W/O重定向。所以在我的例子上面發生的事情是:
[1] GET http://my.joomla.site/getfoo/1234 REDIRECTS TO
[2] GET http://my.joomla.site/index.php?option=com_foo&id=1234 RENDERS PAGE
我需要的是
[1] GET http://my.joomla.site/getfoo/1234 RENDERS PAGE
幾乎所有的東西我嘗試在一個500錯誤。我覺得這應該是簡單的事情,但是現在讓我摔倒了。
謝謝!我認爲可能有更好的方法。我還沒有完全解決這個問題,因爲我在解析路由和隱藏的菜單時遇到了問題,但我很接近。 –