I'm working on a custom theme template for Word Press and I was wondering how to read the variables from the SEO friendly URLS. The website admin can choose between standard URLS http://yourdomain.com/?p=10, which is easy enough to read from with $_GET['p']. But how do I go about reading from the SEO friendly urls http://yourdomain.com/your-page-name/.
Thanks.
Are you on the page http://yourdomain.com/your-page-name/ trying to get the $_GET['p'] value? Just call $_GET['p'] it should work and should have a value of your-page-name. To my understanding mod rewrite only masks the look of the address for the browser bar, but the url is on server side still handled the same way.
Or are you on a different page and you are examining the link http://yourdomain.com/your-page-name/ trying to figure out how to get your-page-name as a variable? For that I would suggest you do either a string split, string position, explode, or regular expression... Many options I think.
Related
I have a custom wordpress page that I wanted to make its url SEO friendly.
So I added some code using rewrite api to convert this url:
http://example.com/page1/?id=1234
to:
http://example.com/page2/1234
page1 is still there and first url still valid. page1 was not very descriptive so I though that since I'm rewriting the url I might as well rename the page too.
Everything on the website works fine, but when I recreated the sitmap xml file and resubmitted to google I was hoping google would forget the old url and start showing the new one. This was a few weeks ago and I'm still seeing old urls. Any idea how I can remove the old urls? Do I need to physically rename the page itself?
Please help.
Thanks
Since google has indexed old URLs, it will stay in their index unless you do something about it. There are two options you can handle.
If you want the old urls to coexist, you can do rel="canonical" on the old URL pages. Canonical will indicate that they are same pages with different urls.
Other option is doing 301 redirect. 301 indicates that the page has moved permanently and it helps search engines to carry over the SEO values of the old urls to the new ones. In due course search engines will index the new urls and old urls will go away. After a certain point in time, once you are sure that old URLs are not receiving any traffic, you can get rid of the redirect rule.
I am working on this site developed in Wordpress 3.3.1. My client wanted me to develop a public page. This page will be a simple php page. It will reside in wordpress directory but will not be a part of CMS itself. The issue here is that I want a url redirection for this page. My client wants to send a link in email to members of the website, so he wants to keep the url clean.
This is the format of current url that he wants to send to the members:
'http://www.example.com/shop/"url_encoded_category_name"/product/"product_id"'
And I want to redirect it to:
'http://www.example.com/template-public-home?productId="product_id"'
I was rewriting the url for now. But as you can see in the first url format that "url_encoded_category_name" and "product_id" are variables and therefor rewriting would mean that I am trying to rewrite different urls to same url(only query string changes). I want to change it to redirection because as I understand this approach of rewriting multiple urls to the same url is penalized by most of the search engines.
For rewriting I edited the .htaccess file.
What I wanted to ask is that considering that I have a publicly accessible page within wordpress directory:
what is the most suitable way to redirect my url?
In my case what is a better Code? 301 or 302?
Thanks for any assistance you can provide or direct me to a source where I could learn about it.
First of all, if your client just wants to use the generated URL in emails to members, no search engine will ever know. However, if there is a chance that they leak you might indeed end up with duplicate content. Redirection then is the correct approach.
You can redirect just as you rewrite by using the [R] flag in your rule (usually in conjunction with L as [R,L] so that the rules below that match are not executed.
From the point of view of a search engine (and a user as well), these are permanent redirects - you will never ever use the URL in the email as a primary URL (or will you?). That means you should use R=301.
Take a look at the documentation to learn about the flags, test your rewrite rules online here and check https://stackoverflow.com/questions/1426056/good-htaccess-mod-rewrite-url-rewriting-tutorial for some hands-on material.
I'm making a website based fully on Ajax, but i'm still doubting about my SEO.
In my "a" tags href I put a Direct link to the content, but i don't redirect the user to it, instead i get the content by Ajax, then I change the Address bar with "window.location.hash".
If i send to Google my sitemap with the two links (the hash link and the direct link) is that going to be a duplicate content and hurt my SEO or not.
If you have any better way to do this (instead of my way) please feel free to tell me about it.
Thanks Guys
Google has a useful guide here:
Making AJAX Applications Crawlable
For full ajax sites, you'll typically see the navigation of the site reflected in url hashes:
#/about or #/faq and so on. When that is the case, google will index the content of those ajax responses if you prefix the url structure with an exclamation point (!). This is called a hashbang. so:
#!/about would actually get indexed by google.... also you can throw those types of urls into your sitemap (i think)
I have an existing PHP/MySQL search for my website (which is in production at the moment).
Visitors can search the website via a $_GET form (by entering the search term).
The $_GET URL looks like -> http://localhost/search/the term (the reason I'm using $_GET is so the search results can be easily directed too. Also because I have pagination on the search php file which is where $_GET['term'] becomes usefull (accross the various pages)).
I'm using mod_rewrite for SEO friendly URLs accross the whole site, so I'm worried that having the search URL like this would affect the consistent SEO URL flow of the website...because the visitor could easily enter non alpha-numeric characters....
Appreciate all responses.
Visitors can search the website via a $_GET form.
That's all right.
BUT search engines DO NOT use your forms!
So, there is nothing to worry about.
I have a PHP system containing user-generated pages, arranged in a complex and non-uniform hierarchy. Pages are created by users, and some pages have sub-pages etc.
I have been asked to add a shortened-url system. So any page, at any point in the hierarchy, can be accessed via domain.com/XXXX where XXXX can be anything - we are not interested in SEO here, the reasoning behind this is its a very social-media driven project, and we would like our users to be able to tweet/other the url of any page they like.
I expect something like; we start on AAAA and head towards ZZZZ as each page is created. Each of these slugs would be stored in the database alongside the actual url eg domain.com/projects.php?p=32
I know mod-rewrite enough to convert domain.com/XXXX into domain.com/index.php?slug=XXXX, but where to go from there leaves me a little stumped. index.php can do the database lookup and header() the user to the actual url, but the slug-url needs to stay in the address bar.
Would using an iframe in index.php be a terrible idea?
I hope thats clear, thanks for reading!
If you used the [R=301] directive at the end of an .htaccess rewrite rule, it will act as a redirect. Meaning if you go to domain.com/XXXX it will show domain.com/index.php?slug=XXXX in the address bar. Is that the behavior you're trying to accomplish?
Also, I wouldn't use a header(), I'd make your index page be the processing page. Either that, or use an include() method instead.
I think using an iframe is a terrible idea, and will lead to a brittle site.
Is there any reason why index.php can't act as a front controller, so instead of redirecting it just shows the page? You should just be able to include the page.
Alternatively, could you not rewrite domain.com/XXXX to domain.com/projects.php?slug=XXXX, and do a slug->p conversion at the top of projects.php? Then the conversion would just need to record slugs and page ids, rather than slugs and full URLs.