[英]How can I set the .htaccess mod_rewrite not on localhost?
I have a domain and a webpage. 我有一个域和一个网页。 I have been trying to create a dynamic website.
我一直在尝试创建一个动态网站。 It's done, but I can't configure my SEO-friendly solutions on my server, just on my local server.
已经完成了,但是我无法在服务器上配置本地SEO友好型解决方案。 This is my PHP code:
这是我的PHP代码:
$host = '';
$base = '/something/';
$baselength = strlen($base);
$url = substr($_SERVER['REQUEST_URI'],$baselength);
$url = array_merge(array('path'=>''),parse_url($url));
$get = explode('/',$url['path']);
$_GET['oldalak'] = ($get) ? array_shift($get) : '';
$_GET['aloldal'] = ($get) ? array_shift($get) : '';
$oldal = isset($_GET['pages']) ? $_GET['pages'] : '';
$oldal = 'pages/'.basename($oldal).'.php';
$oldal = (file_exists($oldal)) ? $oldal : 'pages/kezdolap.php';
$aloldal = isset($_GET['services']) ? $_GET['services'] : '';
$aloldal = 'pages/services/'.basename($aloldal).'.php';
This is my .htaccess code: 这是我的.htaccess代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /something
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(/([^/]+))? index.php?pages=$1&services=$3&%{QUERY_STRING}
</IfModule>
It works! 有用! But, I really do not know, what can I do, that this code work on my server.
但是,我真的不知道,该怎么办,该代码可以在我的服务器上工作。
I tried to everything. 我尽力了。 I modified to my code.
我修改了我的代码。 This is my new code.
这是我的新代码。
$host = 'http://something.hu';
$base = '';
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(/([^/]+))? index.php?pages=$1&services=$3&%{QUERY_STRING}
</IfModule>
My webpage is not in a sub-directory, therefore rewrite base conditions are okay. 我的网页不在子目录中,因此可以重写基本条件。 Same as with the
$base variable
. 与
$base variable
。 Or not? 或不? I tried to modify to this:
我试图对此进行修改:
$host = 'http://something.hu';
$base = 'http://something.hu';
I tried to modify to something else, it hasn't been working on my service provider. 我尝试修改其他内容,但尚未在我的服务提供商上使用。 Why is this the case?
为什么会这样呢? Thanks!
谢谢!
Your RewriteBase
should end in a slash and be identical to your $base
variable. 您的
RewriteBase
应该以斜杠结尾,并且与$base
变量相同。 For no subdirectory, they should both be just /
对于没有子目录,它们都应该只是
/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.