[英]How can I set the .htaccess mod_rewrite not on localhost?
我有一个域和一个网页。 我一直在尝试创建一个动态网站。 已经完成了,但是我无法在服务器上配置本地SEO友好型解决方案。 这是我的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';
这是我的.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>
有用! 但是,我真的不知道,该怎么办,该代码可以在我的服务器上工作。
我尽力了。 我修改了我的代码。 这是我的新代码。
$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>
我的网页不在子目录中,因此可以重写基本条件。 与$base variable
。 或不? 我试图对此进行修改:
$host = 'http://something.hu';
$base = 'http://something.hu';
我尝试修改其他内容,但尚未在我的服务提供商上使用。 为什么会这样呢? 谢谢!
您的RewriteBase
应该以斜杠结尾,并且与$base
变量相同。 对于没有子目录,它们都应该只是/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.