简体   繁体   English

apache2中的友好网址

[英]Friendly url in apache2

Now, have the next .htaccess (in the root folder): 现在,进行下一个.htaccess(在根文件夹中):

Options -Indexes
Options -Multiviews

RewriteEngine on

# Ocultar extension php (hidden .php)
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

# Url amigable (frienly url)
RewriteBase /
Rewriterule ^owner/servicios/(.+)/$ owner/servicios.php?servicio=$1

I expect when the user access try to "domain.com.ar/owner/index/" show the page "index.php". 我希望当用户访问尝试“ domain.com.ar/owner/index/”显示页面“ index.php”时。 This not work, but, i access "domain.com.ar/owner/index" works. 这不起作用,但是,我访问“ domain.com.ar/owner/index”起作用。

On the other hand, when the user try to access "domain.com.ar/owner/servicios/servicio_uno/", $_GET value of "servicio" should be "servicio_uno", but is: "servicio_uno/.php/servicio_uno ". 另一方面,当用户尝试访问“ domain.com.ar/owner/servicios/servicio_uno/”时,“ servicio”的$ _GET值应为“ servicio_uno”,但应为:“ servicio_uno / .php / servicio_uno” 。

And "domain.com.ar/owner/servicios/servicio_uno" shows 500 internal error. 并且“ domain.com.ar/owner/servicios/servicio_uno”显示500内部错误。

Any ideas ?. 有任何想法吗 ?。

depending on where is your htaccess located (root directory or /owner directory) 取决于您的htaccess所在的位置(根目录或/ owner目录)

//if in root
RewriteBase /
Rewriterule ^owner/servicios/(.+)/$ owner/servicios.php?servicio=$1


//if in owner directory
RewriteBase owner/
Rewriterule ^servicios/(.+)/$ servicios.php?servicio=$1

Hope it helps. 希望能帮助到你。

Try the following 尝试以下


RewriteEngine On
RewriteBase /owner/servicios/

RewriteRule (.*) /owner/servicios.php?servicio=$1
RewriteRule ^owner/servicios/servicios.php/(.*) servicios.php?servicios=servicios=$1 [QSA,L] 

 

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM