简体   繁体   English

特定URL的.htaccess重写规则

[英].htaccess rewrite rule for specific URL

When user hit a URL like this 当用户点击这样的网址时

www.mydomain.com/premium-pro/somepage.html

It should map to the www.mydomain.com/myfile.php 它应该映射到www.mydomain.com/myfile.php

and I should be able to access somepage.html as a $_GET parameter in myfile.php 我应该能够访问somepage.html$_GET参数myfile.php

I have .htaccess under mydomain.com but very new to rewrite rules and not sure what kind of rule should be written there. 我在mydomain.com下有.htaccess ,但是重写规则非常新,并且不确定在那里应该写什么样的规则。 I did research on this but didn't get succeed. 我对此进行了研究,但没有成功。 Please help 请帮忙

Try with below rule in root, I've taken a var variable for $_GET data. 尝试在根目录中使用以下规则,我已将var变量用于$_GET数据。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} ^/premium-pro/(.+)
RewriteRule ^ myfile.php?var=%1 [L]

Try this: 尝试这个:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule myfile.php ./premium-pro/somepage.html

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

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