present a static page url as different url which is SEO friendly - mod-rewrite

I have developed a site, which has some static pages. Like explore, home, feedback.
The link for these goes as follows
website.com/views/explore.php
website.com/index.php
website.com/views/feedback.php
I want to write a different SEO URL for each of the URL mentioned above.
Is it possible ?
i.e. for example
website.com/views/explore.php should be convereted/visible as website.com/explore
website.com/views/feedback.php should be convereted/visible as website.com/give/feedback
and so on

You can use these mod_rewrite rules to rewrite requests to /explore and /give/feedback internally to /views/explore.php and /views/feedback.php:
RewriteEngine on
RewriteRule ^explore$ views/explore.php [L]
RewriteRule ^give/feedback$ views/feedback.php [L]

with .htaccess file you can change any url on your site. i love this file.

if you are hosting website in ISS the you can try IIS SEO toolkit. & set dynamic URL itself in IIS
see the indepth explaination by Scott about Imporve SEO by SEO Toolkit

Related

How to do 301 redirect in herokuapp free hosting?

I am trying to do 301 redirect in my herokuapp. How can I do it. I have used <link rel="canonical" href="http://mysite.herokuapp.com">. And I have also used this tag for every page with the url of the page. Still I failed to fix 301 redirections problem in my heroku website.
With url http://mysite.herokuapp.com website is working but with url
www.http://mysite.herokuapp.com it shows
This site can’t be reached
Yoast seo shows this message
"Warning, no 301 redirects are in place to redirect traffic to your
preferred domain. Pages that load successfully both with and without
www. are treated as duplicate content! "
For this problem my website is not indexing in google, I think. How can i show my website in google search.
Note: I have submitted my website to google search console and verified it.
Please help me to solve this problem.
You will want to use something called htaccess
There should be a file in the root of your web directory called ".htaccess" If not create one.
You want a rule something like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.herokuapp.com [NC]
RewriteRule ^(.*)$ http://mysite.herokuapp.com/$1 [L,R=301]
This should redirect www traffic to a none www prefix

How to eliminate a sub-directory level from all URLs in Website

I have a website and I just setup an os shopping cart (ie., Magento)
I installed the cart in a sub-directory off the document root as /magento/ per the installation guidelines.
So my web site cart's URL is http://mydomain.com/magento/
I have no public pages off the document root and I actually want my cart to be my home page -- in other words, I want http://mydomain.com/magento/ to resolve as http://mydomain.com/
Is it possible? Can I use mod-rewrite to make it happen? If so, can you suggest what the mod-rewrite directives would look like?
Or is it simply a permanent redirect like:
redirect 301 /magento http://mydomain.com/
Thanks.
You can use:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/magento
RewriteRule ^(.*)$ /magento/$1
In this way, it should replace everything with /magento in front of it. So, you can have your links to point on your root.
I've edited and tested it, it works.
Now that I've better read your question, it seems you want to redirect only the home page, and not the whole site:
RewriteEngine on
RewriteRule ^$ /magento/

URL Rewrite for Internal (SEO) that Eliminates Original Link

My site is built in php and I have URL rewrites to make the .php links more SEO friendly:
RewriteRule ^page-one$ /pageone.php [L]
The problem with this is that someone, including Google bots, can still see pageone.php from when it was previously indexed. So I end up with two links for each page. That's bad.
How can I set this up so that I get the benefit of rewriting to page-one, while somehow making sure an external request to pageone.php is redirected to page-one?
How about redirecting page-one.php to pageone?
RewriteRule ^page-one.php$ /pageone [R=301,NC,L]

For SEO URLs via .htaccess do extensions need to be 301'd as well?

After researching, I have come to some conclusions for utilizing SEO URLs. For semi-static .php based sites that have file names such as index.php, about.php, contact.php etc I am using htaccess mod_rewrite rules so that for example 'www.mysite.com/about' can be used in place of 'www.mysite.com/about.php'. In such cases, all of my menus and links are then pointing at the SEO URL.
What I have found out though, is that even though nothing in my site references the .php extensions, if I enter them directly, they stick. So, I can get to the about page using /about or /about.php, and each will show as entered. It seems reading through posts here that this is a common issue.
My question is, does this matter? If nothing in my site references the .php extensions in a link or menu, do i need to be worried about duplicate content??
I was told I need to add something in htaccess like:
redirect 301 /about.php http://www.mysite.com/about
for each page to eliminate the possibility but I don't understand if this is really an issue in this case?
Two Questions:
Q1. "Does this matter"?
Answer: Not if you've never exposed the .php URLs before. If you have, then the answer changes to "yes".
Q2. What .htaccess?
Answer:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [R=301,L]
Your URLs are SEO friendly if there are some keywords in it that relate to the content and if they are not overly dynamic in a sense that Google Bot can interpret them (take a look at the Google Webmastertools and read this).
So I would not worry about "mysite.com/about" versus "mysite.com/about.php". I would rather watch out to avoid duplicate content if you want to change the URLs.
Here are some more links for further reference:
Making Website URLs SEO Friendly and Pretty
Some articles and advice on Duplicate Content

Rewriting a Subdomain with mod-rewrite

I have a project that uses the moodle library. I had to change the URL from moodle.example.com to learn.example.com, due to a client request.
I thought this would be an easy change, but alas moodle inserts all links and images in with the complete url instead of the relative url.
Is it possible using mod-rewrite to point all requests to moodle.example.com to learn.example.com and maintain the query string?
Example:
I want a request to: http://moodle.example.com/course/view.php?id=2&topic=1 to go to http://learn.example.com/course/view.php?id=2&topic=1.
Is this possible?
Thanks,
Josh
Try this rule:
RewriteCond %{HTTP_HOST} =moodle.example.com [NC]
RewriteRule ^ http://learn.example.com%{REQUEST_URI} [L,R=301]
In addition to the apache rewrite rules, it may also be worth looking at the moodle documentation on migration: http://docs.moodle.org/en/Moodle_migration
In particular look out for admin/replace.php. This tool can help you to rewrite links across all text in the moodle database at the same time.

Resources