Over the past few days, I have been working on a new website. As of now, I have chosen to go with something similar to that of an MVC: I am using PHP for routing to other pages depending on a value retrieved by GET, changing some settings inside the .htaccess.
When I search for my website on Google, I find three links: one for the website and two for different subdomains:
www.example.comsub.example.comone.example.com
The structure of the links on my website looks like this, because of the routing:
www.example.com/test/bedev.example.com/that/this
This is my .htaccess in case you need it:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
RewriteBase /
All the different parts of the website are linked together with a href, but I worry that may not be enough to make it fully SEO.
Is this a problem going to be a problem? Is there anything I can do about it?
Edit: what I am asking is whether or not this type of layout will be a problem regarding SEO. If that is the case, my follow-up question is what way I would go about fixing it, which most certainly would be a programming-related task (and so the question is not off-topic).
Related
I have some issues while developing my site. I want to realize multilanguage web site, but i don't know how to make correct redirecting for visitors.
For example, the user has come to my web site http://web-site.com/ua/ he sees the default language, and when he walk around through the site he needed to change to english language http://web-site.com/en/.
And now is the problem, how should i realize the next, when he is on product page or other, for example now is:
http://web-site.com/ua/automotive/wheels/product_url
and he is changing language, so now url would be look like this:
http://web-site.com/en/automotive/wheels/product_url
But i don't know how to make the redirect for the same url but with /en/ instead of /ua/. Can some one help me? Or what solutions would be better.
My .htaccess file:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !^favicon\.ico
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
Or maybe it would be better make some redirects in .htaccess from http://web-site.com/ to http://web-site.com/en/. But this is another question.
I did my own router, not like the usual MVC routers, but very similar. If necessary, i will add it below at this question.
I have searched around but I cant find a solution, that covers all of my aspect.
I want this URL
www.site.com/page/underpage
To go to:
www.site.com/?p=page_underpage
WITHOUT the url field to change.
I know that I can use 301 redirects in .htaccess for every link, but the link keeps changing in the URL.
The reason is that I like this linking much better than the PHP queries. I see that almost all other sites has it as well.
But also a last question:
Is this not a good idea? Will it effect SEO?
Try this in your htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /?p=$1_$2 [NC,L]
This internally redirects "/page/underpage" to "/?p=page_underpage" .
I found lots of topics on how to localize a website and most common solutions have been adding subdomains or creating different subdirectories(eg. "/en/"). However I could not find anything that worried about loosing Google indexing for sites that originally were localized for only one language.
Since now, Google managed to index pages like this:
http://website.com/threads/this-is-the-title/11111
Whenever I decide to opt for localizations in different sub-directories, it would be:
http://website.com/en/threads/this-is-the-title/11111
What will happen to the hundreads of pages index by Google? Can you help me figuring out a solution to localize a website without having trouble with Google?
What I found that partially solves the problem
Hreflang: https://support.google.com/webmasters/answer/189077?hl=en
This would work except for the fact that I'll find myself with localization on two different folder levels:
/
...files of already index content
/en
...files of the second language
Update:
Current htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^threads/(?:([a-zA-Z0-9-_]+\/)?)([0-9]+)$ thread.php?qid=$2 [QSA,L]
...other
I turned that line into:
RewriteRule ^(?:([a-zA-Z]+\/)?)threads/(?:([a-zA-Z0-9-_]+\/)?)([0-9]+)$ $1/thread.php?qid=$3 [QSA,L]
This is not enough, since it does not redirect to a localized sub-directory.
Use .htaccess and mod-rewirte to tell google that the url has moved to another uri
for example
RewriteEngine On
RewriteRule ^oldsite\.html$ /newsite.html [R=301,L]
And google is fine with you
I'm currently in the progress of creating a huge website, but instead of the regular URLs I'd like to use Clean / User Friendly URLs. I have been searching on how could I basically tailor these Apache Mod Rewrite rules for my needs, howere I could not found any solution for my particular problem.
Below you can read the aim, which I'd like to achieve with the URLs (I'm not going to write the domain name each time, just imagine: http://www.example.com ahead of the URL parts).
/register/ OR /register ---> /register.php (It should support both of the variations.)
I actually have more files for the registration and I'd like them to be accessible using the "part" words like:
/register/part1/ OR /register/part1 ---> /register.php?part=1 (It should support both of the variations.)
Also, what if I have more than just one query varialbe? (Like "personal=1")
/register/part1/personal/ OR /register/part1/personal ---> /register.php?part=1&personal=1
And what if I have many more of these queries, but I CAN'T specify all of them before? Any of these can be entered. (Like "thing,name,job,etc")
/register/part1/personal/Nicky/ OR /register/part1/personal/Nicky ---> /register.php?part=1&personal=1&name=Nicky
OR any kind of variations you can imagine:
/register/part1/personal/thing/employee/ OR /register/part1/personal/thing/employee ---> /register.php?part=1&personal=1&thing=1&job=employee
EDIT:
This is what I've tried yet, but it just redirects the pages to index.php :/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
So I have given you a lot of examples, what I'd like to basically achieve. I can have a lot of other pages besides "register.php" so it shouldn't be specific to that page only. I also want that which is VERY important, that IF someone goes to for example: register.php?part=1 it should redirect them to the appropriate Clean URL (of course in PHP).
I would also want to ask what should I do in the PHP end to make everything good? I saw that Wordpress has a really great solution for this, which is pretty automatic, and it looks great!
Is there any ways that someone could please explain me how to create a great .HTACCESS mod_rewrite solution for this? I would be really-really glad!
Please do not mark this question as duplicate, because I really did not found anything specific for my case.
You mentioned WordPress, which has something like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
What this does is redirect any request that doesn't match a real file or directory to the index.php script. That script will then decide what page to display. It will do so by looking into $_SERVER['REQUEST_URI'] which holds a path like register/part1.
It would be easier for you to figure out what page to show using this method, because in PHP there are many ways to parse that path string, then map it to a function
You should be able to construct clean URLs like this from your htaccess:
RewriteEngine On
RewriteRule ^index\.html$ /index.php?pageID=Home [L]
RewriteRule ^about-my-homepage\.html$ /index.php?pageID=About [L]
RewriteRule ^contact-us\.html$ /index.php?pageID=Contact [L]
the first is the one you want to output (the "clean" URL), the second one the one you actually want to open. Good Luck!
I'll be signing businesses up to advertise on my website, and I want them to have a direct URL for their customers to go to.
Like, instead of www.website.com/page.php?id=324234234,
I want to have www.website.com/businessname
Is there a simple way to do this? I've searched and seen a whole bunch of different things people are trying to do but I haven't seen anything that's the same as what I want to do.
I'm using a VPS, and I want to make sure that I don't open up permissions so that anyone can get in there and mess things up.
Also, these users will not be signing themselves up. I will be doing that.
The simplest way to get my end result is what I'm looking for. Thanks!
Basic URL rewriting could work.
Add to your .htaccess file
RewriteEngine on
RewriteRule ^(.*)$ page.php?businessname=$1 [L]
Then use PHP to rewrite the businessname to the ID of the company / find the data.
Of course .htaccess rewrite rules is a complete science if you need more complex rewriting...
Re-iterating what jtheman said with a little more explanation:
Create a file named .htaccess with the contents:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page.php?businessname=$1 [L]
You need, of course, the ability to have directory level .htaccess enabled - you're using a VPS so you should be able to do this if it is not already enabled.
So let me explain what each line will do.
RewriteEngine on
Turns on the ability to URL re-write
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Tells Apache not to re-direct files that exist in the directory already
RewriteRule ^(.*)$ page.php?businessname=$1 [L]
This is where the magic happens.
^(.*)$ this part is like a regular expression match. It will tell Apache to collect any URLs that have any characters within them and redirect them to page.php?businessname=(.*)
So, if you post:
www.website.com/stackover
It will really be sending: www.website.com/page.php?businessname=stackover
Then you can just use $_GET[businessname] to dynamically update the page.
Hope this helps!