Jump to content

Danielx64

New Members
  • Posts

    1
  • Joined

  • Last visited

Danielx64's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello all, Just wondering if I could get some help here. I'm almost finished with building my CMS system, and something that I been trying to get working is that if someone use the wrong url format, it would do a 301 redirect and carry on. I am struggling to work out what I'm doing wrong. When $config['blog_seo_enabled'] is set to on and I go to http://localhost/?p=test the url would change to http://localhost/test that is expected. When I turn $config['blog_seo_enabled'] off, and I head to http://localhost/test I am getting redirected to http://localhost/?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=?p=test with firefox throwing up "The page isn't redirecting properly" when I should be getting http://localhost/?p=test. $page_url = request_var('p', ''); $page_url_rewrite = substr(rawurldecode($_SERVER['REQUEST_URI']),1); if (preg_match('/^index\./', $page_url_rewrite)) { // The user probably wanted the home page header('HTTP/1.1 301 Moved Permanently'); redirect($config['server_protocol'].$config['server_name'].'/'); } if($page_url && $config['blog_seo_enabled']) { //echo($config['server_protocol'].$config['server_name'].'/'.$page_url); //exit(); // If seo links are enabled and someone trying to access via /?p=* we redirect then to the correct page (/*) header('HTTP/1.1 301 Moved Permanently'); redirect($config['server_protocol'].$config['server_name'].'/'.$page_url); } elseif($page_url_rewrite && !$config['blog_seo_enabled']) { // If seo links are not enabled and someone trying to access via /* we redirect then to the correct page (/?p=*) header('HTTP/1.1 301 Moved Permanently'); redirect($config['server_protocol'].$config['server_name'].'/?p='.$page_url_rewrite); } Could someone please let me know how I should be doing it? My .htaccess looks like this RewriteEngine On RewriteRule ^a/([0-9\-]+)/?$ index.php?b&a=$1&seo=1 [QSA,NC] RewriteRule ^s/\??author_id=([0-9]+)$ index.php?b&author_id=$1&seo=1&search [QSA,NC] RewriteRule ^s/(.*)$ index.php?b&keywords=$1&seo=1&search [QSA,NC] RewriteRule ^resources/([0-9]+)/(.*)$ index.php?downloadfile&i=$1&checkseo=$2 [QSA,NC] RewriteRule ^rss/([a-z]+)\.html$ rss.php?mode=$1&seo=1 [QSA,NC] RewriteRule ^rss/([a-z0-9-]+)/([a-z]+)\.html$ rss.php?b&ci=$1&mode=$2&seo=1 [QSA,NC] RewriteRule ^c/([a-z0-9-]+)/$ index.php?b&ci=$1&seo=1 [QSA,NC] RewriteRule ^c/([a-z0-9-]+)/([a-z0-9-]+)/?$ index.php?b&cp=$1&ci=$2&seo=1 [QSA,NC] RewriteRule ^([a-z0-9-]+)\-p([0-9]+)\.html$ index.php?view&p=$2&checkseo=$1 [QSA,NC] RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+)\-p([0-9]+)\.html$ index.php?view&ci=$1&p=$3&checkseo=$2 [QSA,NC] RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)\-p([0-9]+)\.html$ index.php?view&cp=$1&ci=$2&p=$4&checkseo=$3 [QSA,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] Thank-you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.