Welcome Guest, Not a member yet? Register   Sign In
routing with "/" in the end of query string
#1

[eluser]Unknown[/eluser]
Hi all. I can't solve my problem. I need that category on my site have "/" in end of url.

Example: http://mysite.com/programming/

Now it works with / and without /

In my .htacces:
RewriteCond $1 !^(index\.php|images|uploads|css|robots\.txt|sitemap\.xml|favicon.ico|templates)
RewriteRule ^(.*)$ /index.php?$1 [L]

And in routes.php:
$route['^([0-9a-zA-Z_-]*)(/?)+$'] = "category/get_post_by_category/$1";

If i do like this:
$route['^([0-9a-zA-Z_-]+)/$'] = "category/get_post_by_category/$1";
I get 404 error, and if I do like this:

$route['(:any)/'] = "category/get_post_by_category/$1";

I get 404 error again.

Please, help me solve this problem. The search engines not indexing my site because content is doubling because urls works with / and without /
#2

[eluser]CroNiX[/eluser]
Search engines can't catalog what they don't see on your site. Somewhere, you are creating links with and without the trailing slash for the same url. Find them and make them all consistent.

You can also help with htaccess and remove trailing slashes (or add) from all requests, but you should be making your links consistent to begin with.

Here's what I have in my htaccess at the top before any CI specific rules, it may or may not work on your server. It redirects with a 301.

Code:
RewriteRule ^(.+)/$  /$1 [R=301,L]




Theme © iAndrew 2016 - Forum software by © MyBB