简体   繁体   中英

Codeigniter .htaccess redirect url issue

I want redirect my old url to new url the redirection is working fine but there is an issue in url, the redirected url is not in proper way

For Example :

Old url :www.example.com/pages/product_popup/1

New url : www.example.com/product-syrup

But it is redirecting in this way

Redirected url : www.example.com/product-syrup/?/pages/product_popup/1

My htaccess:

RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]


Redirect 301 /pages/product_popup/1 /product-syrup/



## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

How can i overcome this? Am using GoDaddy hosting

RewriteEngine On的新行中添加以下规则:

RewriteRule ^pages/product_popup/1$ /product-syrup [R=301,L]

In codeigniter you can do this by URI Routing

Under application / config / routes.php

$route['pages/product_popup/(:any)'] = 'product-syrup';

A URL containing the word “pages/product_popup/(:any)” will be remapped to the “product-syrup” class.

https://www.codeigniter.com/userguide3/general/routing.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM