I have a problem with redirecting categori links in htacess file
can you check what I am missing please
news links works but category links dont.
I would like to redirect links wit htaccess
Category link example:
site url/3159-economi.html
// Catogory Original link
cats.php?id=catid
// Catogory Seo link
$news_url_seo = $row[catid]."-".seo($row[category]);
// News Original link
details.php?id=id
// News seo link
$news_url_seo = $anews[id]."-".seo($anews[title]).".html";
Htaccess links
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-(.*).html$ details.php?id=$1&$title=$1 [L,NC]
RewriteRule ^(.*)-(.*)$ news.php?catid=$1&$category=$1 [L,NC]
Related
My website generates page URL with the prefix ?Script=, which is not SEO-friendly.
I want to remove this prefix and just keep the page title.
For example, I want to convert the following URL:
example.com/?Script=about to example.com/about
about is the About page of my website.
I want to set up a rule for omitting ?Script= for all pages.
I have managed to do it for my blog post by using the following rewrite rule.
RewriteRule ^news/([0-9a-zA-Z_-]+) ?Script=news_view&uid=$1
This should work for you .
RewriteEngine on
RewriteRule ^(about)/?$ /?script?=$1 [L]
If you have more pages , you can add those pages to the pattern
RewriteEngine on
RewriteRule ^(about|page2|page3)/?$ /?script?=$1 [L]
I have links that are a joomla blog category that contain articles:
example.com/old-cat-name/art1
example.com/old-cat-name/art2
that i want to redirect to:
example.com/new-cat-name
I don't need to specifically redirect each article from "old-cat-name", I just want ALL of the articles in the old cat name to get redirected to the new category blog:
example.com/new-cat-name
I have admin tools redirect, but this is probably something I need to do in .htaccess.
Here's a sample .htaccess I used when I built a new version of my site and wanted to ensure that visitors to the old pages would be permanently re-directed to the new pages and make sure I didn't lose their seo value with Google:
Options +FollowSymLinks
RewriteEngine On
# Apply to directories (!-d) and files (!-f)
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# Static pages
Redirect 301 /enquiries.php mysite.com/enquire
# Listing pages
Redirect 301 /apartments-city-south.php mysite.com/apartments/city/south
# And this for requests which use to contain url parameters, i.e.:
# mysite.com/view_propery?code=1234
# But are now in the form:
# mysite.com/accommodation-detail/1234
# Property detail pages
# Detail pages
RewriteCond %{QUERY_STRING} ^code=(.*)$
RewriteRule ^detail.php$ accommodation-detail-%1\.html? [R=301,L]
You must ensure that MOD_REWRITE is on in your Apache config file on your server
Note: Because of restrictions in links in stackoverflow answers I could not include a http:// in the code. Please insert this in front of the lines which start with a domain and suffix i.e. mysite.com, NOT the lines which start with a / JUST the ones which start with mysite.com
the below htaccess code work for single URL with same page
RewriteRule ^([^/]*)\.html$ /current/shoppe/sub-category.php?category=$1 [L]
now, i need to rewrite a URL of another page.
Please help, some website is arbitrarily adding dynamic query strings to my home page.
For example my home page is www.mysite.com/index.php and they link to many links like this:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
And those links are opening on my site, content of page are the same for every page, just like my original www.mysite.com/index.php
There are few hundreds of that links pointing to my site. So how I can redirect this:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
...
to
www.mysite.com/index.php or just to www.mysite.com/
This what I tried so far in my .htaccess file
RedirectMatch 302 ^index.php?a= http://www.www.example-ste.com/
RewriteRule ^/index.php?a=(.*) http://www.example-ste.com/
But still pages are opening on site.
Another similar question.
How to redirect pages ending with "?pagewanted=all" to the same page but with out that "?pagewanted=all"
For example I need to redirect page:
www.mysite.com/something-something/something.html?pagewanted=all
to
www.mysite.com/something-something/something.html
Hello.
I just noticed something. I needed URL redirection rule which will redirect pages like:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
to home page of site, root. And you gave me this code:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
And I must say it works fine, it does that, but I just noticed that it somehow blocks or redirect all links containing ?a= for example on some temporary pages I have links like:
i.php?a=something-something-something
So, can you adopt code just for pages based on index.php like:
www.mysite.com/index.php?a=something-something-something
and not for links with:
i.php?a=something-something-something
If I am right it works on all links with "a=" but I need just for "index.php?a="
Try adding the folloginw to the top of your .htaccess file
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
#if the query string has a pagewanted parameter
RewriteCond %{QUERY_STRING} (^|&)pagewanted=all [NC]
#Redirect and remove query string parameters for html pages
RewriteRule (.+\.html) http://www.mysite.com/$1? [R=301,L]
Edit.
Added rule to remove pagewanted=all
I have some old indexed pages in Google that need to be redirected to their new locations. Example: Google shows wwww.domain.com/pages/subpages/page.php that is now in www.domain.com/pages/page.php.
I also need, when someone clicks on the old page in Google, to open rewritten URL.
Example: User clicks on wwww.domain.com/pages/subpages/page.php, it will open him wwww.domain.com/pages/page.php, but with www.domain.com/page in address bar (without "pages/" and php extension).
So I have written this .htaccess code
Redirect 301 /pages/subpages/page.php http://www.domain.com/page
RewriteEngine On
RewriteRule ^page/?$ /pages/page.php
The redirect works, but user have in address bar full URL (http://www.domain.com/pages/page.php), not the rewritten one(http://www.domain.com/page). It looks like the mod_rewrite doesn't work with redirect or something.
Is there any solution?
This code works fine for me:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# 301 redirect
RewriteRule ^pages/subpages/page\.php$ http://www.domain.com/page [R=301,L]
# rewrite
RewriteRule ^page/?$ /pages/page.php [L]
Please ensure that you have no other redirects/rewrites in your htaccess file as they may may perform additional rewrite/redirect actions.