I've made my php website url fiendly with url re-writting as,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[A-Za-z0-9-_]+/([A-Za-z0-9-_]+)/?$ product.php?uni_id=$1 [NC,L] #
So, Old urls were,
http://example.com/product.php&uni_id=laptop-123
and new url is,
http://example.com/products/laptop-123/
Now, When search engine comes back they should informed about (old url is permenently moved to) new url or i can remove all entries from search engines in order to get rid of duplicate entries in search engines.
Now, what i have to do after writing url in terms of seo purpose.
NOTE : I've heard about using 301 redirects but don't know how to implement it.
To improve your SEO you should add canonical URLs.
You do that by adding a canonical url in the head of the page in question, so in your example:
<link rel="canonical" href="http://example.com/products/laptop-123/">
That way for example Google knows which url to index and it will not penalize you for duplicate content.
Note that this is only one of the (easiest...) ways to achieve this, you could for example also do a 301 redirect when a visitor is not using your preferred url.
Also see the information from Google itself.
Related
I have used URL rewriting with .htaccess with the below code. Problem is that if we paste the URL then it's working but auto redirection is not working.
.HTACCESS CODE:
Options +FollowSymLinks
RewriteEngine on
RewriteRule Sports-Equipment-Catname-(.*)\.html$ Sports-Equipment.php?Catname=$1
My URLS:
http://example.com/Sports-Equipment.php?Catname=Discus
If I paste direct URL from htaccess is:
http://example.com/Sports-Equipment-Catname-Discus.html
why URLs is not auto-redirected to new pages.
Please help me to fix it.
why URLs is not auto-redirected to new pages.
There is no "automatic" process here. You have no directives that implement the redirect.
My URLs: /Sports-Equipment.php?Catname=Discus
That's the problem, you need to change the actual URLs in your HTML source. This should not be resolved with a "redirect". Otherwise, the user can still "see" the old URL before they click the link. If they copy a link they are copying the "old" URL. Every time the user clicks a link they are redirected - which is slow, not just for the user, but also for your server (uses more resources).
However, you should implement a redirect if you are changing an existing URL structure. But this is to preserve SEO only. For search engines that have indexed the old URLs and for third party backlinks to the old URLs.
For that you would need to add the following "redirect" before the existing rewrites. For example:
# Redirect "old" URL to "new" URL
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^Catname=([^&]*)
RewriteRule ^Sports-Equipment\.php$ /Sports-Equipment-Catname-%1.html [QSD,R=301,L]
The condition that checks against the REDIRECT_STATUS env var ensures we only redirect direct requests and not rewritten requests by the later rewrite - thus avoiding a redirect loop.
The QSD flag discards the query string from the initial request.
I am using laravel 5.2 and I have search form which pass GET parameter, so in url its like
http://www.example.com/list/item?&qs=&unit-type=Office&min-bed=&max-bed=&min-price=&max-price=
so search result is shown with such ugly url, I want to make this url seo friendly, I don't want to use post method.
Is there any .htaccess code that can help to make seo friendly url of such get parameter.
I tried this .htaccess code but doesn't work.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
What you are doing is possible, but shouldn't be done.
The page is not a static page, or a product page, or a listing page. It is a search result page.
The search result page should not be SEO friendly in terms of the url containing information about the search query because this is supposed to be dynamic. A search engine will not be interested in indexing a specific user's search result page on your website. A search engine will be interested in indexing the search page.
If you are looking to have a product listing page for example with pre-defined search queries, then why not just create a specific controller and for the time being, manually write an SEO friendly url to point to the required method on that controller?
e.g.
Route::get('offices-between-10000-and-20000-pounds', 'ListingController#getOfficesBetweenPriceRange');
i got a question abount seo friendly urls.
Manly, i would like to know whats the best way to get my system running with seo friendly urls. i have programmed my own cms system which is working at the moment with url like this:
/content.php?contentid=ID
On every content page you can change the Meta-Tags.
Every LINK which is generated in my CMS follows this structure. If i want to use SEO friendly URLs changing every link, or code, where a link is generated, might be a bad idea. So i am looking for a nicer way. Is there any commonly used way to handle this?
My first idea was to automatically generate a new .htacces file with ModRewrite after the MetaTags of a Contentfile have been changed. So the SEO friendly URLs are recognized by the system. To get the LINKs on every page working i was thinking about checking the current url and redirecting to the new seo friendly url at the beginning of the content.php file.
I dont know if this is the right way to work with seo friendly urls. How are other CMS Systems handling this issue? I would be thankful for any inspiration!
if you are using an framework(which i think you are) then you can use a .htaccess like this to send the new cleaner links in an $_GET to the framework:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
My site is:
example.com
My mobile version:
m.example.com
Profile page is
example.com/profile or m.example.com/profile
Or posting page
example.com/posts or m.example.com/posts
Mobile version's url is similar. So, how to redirect the same page?
For example: user go (from facebook) into example.com/posts but he uses mobile device,
so how to redirect via .htaccess to m.example.com/posts
I saw this one threat, but i'm confuse to create right rules.
Thanks :)
Your question is similar to this question, except that you want to redirect the user. First you need a list of mobile user-agents. I am not going to suggest a list, but I think you should be able to find a list that is suitable for you.
Next, you want to go to your .htaccess file and add something like this:
RewriteCond %{HTTP_USER_AGENT} ^(user-agent1|user-agent2|user-agent3|etc)$
RewriteCond %{HTTP_HOST} !^m\.example\.com$
RewriteRule ^(.*)$ http://m.example.com/$1 [R,L]
The first RewriteCond contains all user-agents you want to redirect. Remember that it is a regex, so you have to escape any special characters! The second RewriteCond checks if the host isn't already m.example.com. If we wouldn't check for this, we would create an infinite loop, redirecting to the same url over and over. The RewriteRule itself matches everything after the hostname (and before the query string) and redirects it to the mobile site. $1 gets replaced with the first capture group in the regex in the first argument of RewriteRule. The [R] flag is not necessary in this case (links with http:// will always be redirected), but it let's Apache know that it should do an external temporary redirect to the new url. The [L] flag will stop processing more rules if this rule matches.
See the documentation for more information.
I have a url like this
post_article.php?url=how-to-use-mod-rewrite
I am using mod_rewrite to make it
post/how-to-use-mod-rewrite
Code I am using in .htaccess
RewriteEngine On
RewriteRule ^post/([^/]+)/?$ post_article.php?url=$1 [L]
Now both of this urls will give the same content, which is not good in SEO point of view.
How I can redirect all those old urls to new url.
ie post_article.php?url=any-value to post/anyvalue
Use canonical URLs to help search engines understand duplicate content, if SEO is your sole concern.
RewriteEngine On
Redirect ^post_article.php?url=.*$ post/$1
RewriteRule ^post/([^/]+)/?$ post_article.php?url=$1 [L]
Try it.
Just create a function to rewrite all your links in your articles, and search engines will never be able to find the old url scheme.