更新时间:2023-02-14 22:07:55
.htaccess文件
例如:
RewriteEngine on
重定向^ / exp / go / to / 123 $ /somthing.php [L]
主要之所以使用 / exp / go / to / 123 URL结构,是因为不同的元素可以用作加载页面的变量,在这种情况下,您可以使用:
RewriteEngine重定向^ / exp / go / to /([0-9] +)$ /somthing.php:id=$1 [L]
将从网址中删除123,并将其作为ID参数传递给someting.php。 p>
I have url like this
http://www.abcdef.com/somthing.php
i want use same file content but different url format like this
http://www.abcdef.com/exp/go/to/123
for this where i need to modify either php or htaccess file?
The .htaccess file
for your example you'd use:
RewriteEngine on
Redirect ^/exp/go/to/123$ /somthing.php [L]
The main reason you'd use the "/exp/go/to/123" URL structure is because the different elements can be used as variables to load the page in which case you could use:
RewriteEngine on
Redirect ^/exp/go/to/([0-9]+)$ /somthing.php:id=$1 [L]
which will take the 123 off the url and pass it to the someting.php as an ID parameter.