简体   繁体   English

HTACCESS:URI将所有内容重写为index.php(在同一目录中)

[英]HTACCESS: URI rewrite everything to index.php (Within the same directory)

I have a uri: www.domain.com/leasing/properties/ 我有一个uri: www.domain.com/leasing/properties/

Within that directory, I created a file .htaccess : 在该目录中,我创建了一个文件.htaccess

RewriteEngine on
RewriteRule ^(.*)$ index.php?uri=$1 [L,QSA]

What I want, is that regardless of that users type after properties/ (Ej. www.domain.com/leasing/properties/somethigelse/I-do-not.care/what@#$%they\\type ) to be handled by www.domain.com/leasing/properties/index.php 我想要的是,无论用户在properties/ www.domain.com/leasing/properties/somethigelse/I-do-not.care/what@#$%they\\type )之后键入什么, www.domain.com/leasing/properties/index.php

I do not need structure or anything else. 我不需要结构或其他任何东西。 index.php will grab $_REQUEST['uri'] and check against a database. index.php将获取$_REQUEST['uri']并检查数据库。 So, again, I do not care what's typed after www.domain.com/leasing/properties/ so long index.php can get the URI and handle an action according to $_REQUEST['uri'] 因此,再次,我不在乎在www.domain.com/leasing/properties/之后键入什么,所以很长的index.php可以获取URI并根据$_REQUEST['uri']处理操作

I want the address bar to not not change. 我希望地址栏保持不变。 Whatever a user types, to remain the same. 无论用户键入什么,都保持不变。

The current file is giving me a 404 error. 当前文件给我一个404错误。

PS. PS。 I know close to nothing about Apache .htaccess 我对Apache .htaccess几乎一无所知

Create a .htaccess file with the following: 创建具有以下内容的.htaccess文件:

RewriteEngine On
RewriteRule ^([^/]+)(.*)$     /leasing/properties/ [R]

And place it within /leasing/properties/ folder. 并将其放在/leasing/properties/文件夹中。

RewriteEngine on
RewriteRule ^/leasing/properties/(.*)$ /leasing/properties/index.php [L,QSA]

If that does not work, your Apache server may not be configured to allow .htaccess files. 如果这不起作用,则您的Apache服务器可能未配置为允许.htaccess文件。

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

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