htaccess rewriterule and after slash want to type something

你说的曾经没有我的故事 提交于 2019-12-25 12:13:10

问题


my htaccess file

<Files .htaccess>
order allow,deny
</Files>

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(\w+)/*$ ./load.php?code=$1

load.php

<?php
echo $_GET['code'];
?>

if i typed www.example.com/1995 or www.example.com/1995/ php showing 1995 only. but after slash(/) type something url doesnt work. ex : www.example.com/1995/video-title

i want to if we type www.example.com/1995/video-title php showing 1995 only.

how to do it? help me. thanks...


回答1:


Replacing

RewriteRule ^(\w+)/*$ ./load.php?code=$1

with

RewriteRule ^(\w+)/(.*)$ ./load.php?code=$1
RewriteRule ^(\w+)/*$ ./load.php?code=$1

should allow www.example.com/1995, www.example.com/1995/, www.example.com/1995/video-title, or www.example.com/1995/video-title/ have 1995 printed in the php page.



来源:https://stackoverflow.com/questions/22889268/htaccess-rewriterule-and-after-slash-want-to-type-something

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!