Php 我已经屏蔽了url现在我想更改屏蔽的url

Php 我已经屏蔽了url现在我想更改屏蔽的url,php,jquery,apache,.htaccess,url-masking,Php,Jquery,Apache,.htaccess,Url Masking,几天前,我发布了一个与此相关的问题,我得到了很大的推动。我也做了一些实验和研究,取得了一些好的结果。这就是我所取得的成就。我把它放在我的.htaccess文件夹-“文件夹”中: RewriteEngine On #Look for the word "post" and take everything after "post" and store it in $1 RewriteRule post(.+)$ something.php?file=$1 [L] # allow pu

几天前,我发布了一个与此相关的问题,我得到了很大的推动。我也做了一些实验和研究,取得了一些好的结果。这就是我所取得的成就。我把它放在我的.htaccess文件夹-“文件夹”中:

RewriteEngine On

#Look for the word "post" and take everything after "post" and store it in $1
RewriteRule   post(.+)$   something.php?file=$1   [L]

# allow public pages
RewriteRule ^index.php$ - [L]
RewriteRule ^style.css$ - [L]
RewriteRule ^bg.png$ - [L]
RewriteRule ^cat_bgg.gif$ - [L]
RewriteRule ^cat_bgr.png$ - [L]
RewriteRule ^h1_bg.gif$ - [L]
RewriteRule ^hd_bg.png$ - [L]
RewriteRule ^menu_bg.png$ - [L]

# serve everyone from specific-domain or specific-user-agent
RewriteCond %{HTTP_REFERER} ^http?://www.abc.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^specific-user-agent$
RewriteRule ^ - [L]

# everybody else receives a forbidden
RewriteRule ^ - [F]

ErrorDocument 403 /index.php
这就是它现在的工作原理: 我把一个链接放在:

www.abc.com

作为

www.xyz.com/folder/postsomecode

当有人单击此链接时,根据.htaccess,“somecode”将被获取并存储在$1中,并处理:

www.xyz.com/folder/something.php?文件=$1

并显示此内容。但浏览器中显示的url为:

www.xyz.com/folder/postsomecode

这就是我想做的。而不是显示:

www.xyz.com/folder/postsomecode

我能给你看些漂亮的吗

www.xyz.com/somethingnice

www.xyz.com/folder/someword

我该怎么做?我应该在这行后面加些什么吗 重写规则post.+$something.php?文件=$1[L]


或者有其他方法吗?

我不明白,你希望.htaccess可以随机发布你的帖子吗?它不能那样做。您需要创建另一个php页面somthingtrandom.php,然后向RewriteRule randompost$somethingtrandom.php[L]添加另一个规则,或者您可以修改您的something.php,以便在它没有收到文件参数时检索一个随机帖子,然后只添加另一个规则:RewriteRule randompost$something.php[L]@Zealander没有。我刚才说看到的内容是www.xyz.com/folder/postsomecode,但地址栏中的url应该是一些好的简单的东西,比如www.xyz.com/randompost或www.xyz.com/folder/toppost,甚至www.xyz.com/somethingGood为什么不把链接www.xyz.com/sometcode重新编写文件,甚至.htaccess都只在“文件夹”中。我没有把它们放在根上。