2013-06-26 124 views
-1

我需要从这个更改网站网址:URL重写PHP和的.htaccess

www.thesite.com/thepage.php?lang=it 

这样:

www.thesite.com/it/thepage.php 

但我需要这个,即使该文件夹it不工作存在。

当然,我也需要PHP文件来将www.thesite.com/it/thepage.php读回到www.thesite.com/thepage.php?lang=it

我已经看过很多关于StackOverflow和文档的帖子,但无法弄清楚。

+0

您是否尝试过阅读[文件](http://httpd.apache.org /docs/current/mod/mod_rewrite.html#rewriterule)? – Oswald

+0

我确实尝试过,但无法弄清楚,否则我不会问......而对于昆汀,我确实看过其他答案,但仍然无法弄清楚......我可能很愚蠢,但...... :D –

+0

同时显示您的.htaccess的代码 –

回答

0

这个怎么样

RewriteEngine on 
RewriteRule ^([^//]+)$ thepage.php?lang=$1 [QSA,L] 

为了thepage.php也是一个动态试试这个

www.thesite.com/it/thepage.php 

RewriteEngine on 
RewriteRule ^([^//]+)/([^//]+)$ $2?lang=$1 [QSA,L] 
+0

听起来不错,但“页面”可以是任何页面,如index.php,this.php,other.php等等。那会是怎样的呢? –

+0

看到我编辑的答案 –

+0

看不到原因,但它不起作用:[http://www.aquapol.mc/index.php?lang=it](http://www.aquapol.mc/index.php? lang = it) –

0
RewriteEngine on 
RewriteRule ^([a-zA-z]+)/(.+) $2?lang=$1 
+0

看不到为什么,但它不工作:[http://www.aquapol.mc/index.php?lang=it](http://www.aquapol。 mc/index.php?lang = it)...看看你自己 –