I am building a website and I will need to make it SEO friendly so, as it is now, I am using a dynamic website (PHP) and through .htaccess, I am making it appear as if the site has static pages.
To do this, I am redirecting to a php file which then displays the content.
The url looks like: www.mainpage.dk/phpfile-navigationvalue-value.htm
I am using a navigation value inside the page to render it according to which menu item is clicked.
The guy I am building this for says that a url like www.mainpage/something.html is better for SEO purporses than www.mainpage.dk/phpfile-navigationvalue-value.htm. Can anyone come with some input on this matter?
And if the regular static page is better, is there a way to make a dynamic look just like a regular static page?
PS: The reason why I want a dynamic page is that the page is going to be extended with new pages every now and then as well as updated frequently.
To make it look like a regular page you could add *.html -> alias.php?alias=*
Then check the aliases and display the proper page from PHP.
Also, how about making it :
www.mainpage.dk/phpfile/navvalue/value/ -> index.php?page=phpfile&nav=navvalue&val=value
I would discourage redirecting to a phpfile, but handle it via index.php?page=* (look line above), or something similar.
Edit:
how htaccess should look
RewriteEngine on
# [!]for `*.html` -> `alias.php?alias=*`
RewriteRule ^(.*)\.html$ alias.php?alias=$1 [NC]
# [!]for `/phpfile/navvalue/value/` -> `index.php?page=phpfile&nav=navvalue&val=value`
RewriteRule ^(.*)/(.*)/(.*)(/)?$ index.php?page=$1&nav=$2&val=$3 [NC]
Related
I need to do this using htaccess
When a request is made for http://www.example.com/home, it should (internally)load the page http://www.example.com/home_st.php
Similarly when a request is made to other link called products (http://www.example.com/products), it should (internally)load http://www.example.com/products_st.php
In short what it is doing is appending "_st.php" and loading that URL. But one thing I do not want is if the user directly types http://www.example.com/home_st.php or http://www.example.com/products_st.php in the browser, it should show 404 / Page not found error
I have few other pages in that folder and I want those pages to behave in this manner. I understand the htaccess should have something like this
Turn on the rewrite
Forbid access if the URL is called with page names like home_st.php, products_st.php etc.
If it's "home" or "products", then rewrite(append?) it to home_st.php and products_st.php respectively. I have other files too while need to follow the same
P.N: My URL should not show the actual filename, for example home_st.php, products_st.php etc. It should only show as http://www.example.com/home, http://www.example.com/products etc
htaccess and regex is not something that I am well acquainted with. Any help would be great. Thanks
You want to be able to re-write URL's
This has been written before but i'll say it again.
You want to use the Htaccess file and the re-write rule.
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^pet-care/?$ pet_care_info_01_02_2008.php [NC,L] # Handle requests for "pet-care"
This will make this url: http://www.pets.com/pet_care_info_07_07_2008.php
Look like this: http://www.pets.com/pet-care/
Links to more information: How to make Clean URLs
and for the webpage I used to reference this information from: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
To get your pages set the way you want them, I would advise that you read the two articals and try get what you are looking for.
If you need some specific help with doing this, ask.
Hope that helps.
I have a Wordpress blog installed in a subfolder and I would like to replace a part of the url of the post.
Right now it is like this: http://domain.com/wordpress/{permalink-structure}
What I would like to achieve (without moving the site) is: http://domain.com/{permalink-structure}
I tried changing the site url (and followed the instructions provided by WP on how to do this), but if I do this, my front-end stops working ( I am not retrieving the posts etc through the WP-API and I work with AngularJS)
Is there an easy way to automatically modify the (by wordpress generated) url of all future posts by using a plugin or modifying the source code? Or via .htaccess?
Redirecting via htaccess is my preferred option but when I tried this, the wp-api plugin (accessible via domain.com/wordpress/wp-json/* stopped working
Just to be clear: I am not accessing the posts by the generated URLS, I retrieve them via the API and the only thing I want is that the link object in the retrieved post has a different URL.
I don't know. Just try to help. This is my solution redirect what need to redirect.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^wordpress/wp-json/(.*)$ http://domain.com/wordpress/wp-json/$1 [R=301,NC,L]
RewriteRule ^wordpress/(.*)$ /$1 [R=301,NC,L]
you want to change wordpress domain or URL. you need to perform following steps.
1 you need to modify all url's stored in database. I prefer to use https://interconnectit.com/ tool. It is pretty good and easy.
2 Once you update all database urls then you need to login in wp-admin and just update permalink settings.
you need to check plugins too. Some plugins may get deactivated you need to activate them again.
Hope this will help.
check word press codex:
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
you can display your word press without move your directory from sub folder to root folder and can remove sub-directory from URL.
I'm building a plugin for a WordPress Multisite, and each subsite needs an SEO friendly URL for various tabs that actually appear on the same page.
I have already written the system that detects the correct URL and shows the relevant tab using a query string, but I want to do it without a query string... here's what I mean:
Currently:
http://domain.com/subsite/?tab=contact
Will load the home page of the sub-site, but containing the content of the "Contact" tab. i.e.
if (isset($_REQUEST['tab'])) {
$tab = $_REQUEST['tab'];
// Validate $tab here
get_template_part('tab', $tab);
}
What I Need:
http://domain.com/subsite/contact
To be invisibly rewritten for ALL subsites so that it ends up showing the same content, by rewriting /subsite/whatever to /subsite/?tab=whatever
Any and all help would be greatly appreciated.
I'm not going to judge your methods as others as I know nothing about your project.
To achieve what you need, use mod_rewrite rule like this:
RewriteEngine On
RewriteRule ^subsite/(.+)$ /subsite/?tab=$1
I have a series of pages on my website which are generated identically using php and a database. The only thing that changes is which topic is selected from the database. I want the user to be able to navigate to the each of these topic pages directly like www.mywebsite.com/<TOPIC> where <TOPIC> is the name of ANY topic. So currently I have a source folder in my public html directory along with an index page for each of these topics. As I'm about to add a lot more "topics" I feel like there is a better way to do this.
What I am looking for is for the user to be able to type www.mywebsite.com/<TOPIC> and a SINGLE php script is used to generate a page based on what <TOPIC> is.
The only thing I could think of was using the 404.php page for this and only showing an error if the topic didn't exist. But with that idea, I don't know how I would get what <TOPIC> and feel like that is a hack.
create or edit your .htaccess file in your document root and write this:
...
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [NC,L]
</IfModule>
Then you can call a page like:
http://example.com/this-is-my-topic
and in your index you would be able to handle $_GET["page"] with the value of this-is-my-topic.
That is of course only if your server supports Clean URLs and mod_rewrite.c
In my site, I have used mod rewrite to make search engine and user friendly urls.
Only 3 rules:
RewriteRule ^articles/([a-z]+)/([0-9]+)/?$ /index.php?page=articles&cat=$1&id=$2 [L]
RewriteRule ^articles/([a-z]+)/?$ /index.php?page=articles&cat=$1 [L]
RewriteRule ^([a-z]+)/?$ /index.php?page=$1 [L]
But index.php is still accessible by anyone and will work even if a friendly URL is not used(that is, instead parameters are passed).
So, does this down rank by search engine ? Do I have to block direct access to files with .php extension ?
If you have 2 URLs that load the same page where one is search engine friendly and the other is not, this is not really detrimental to your site AFAIK. Basically you just want to expose to search engines as much as you can, so if you need to provide a parallel track, for example an anchor tag that works fine without Javascript because the action will take you to the correct place (which is ideal for a bot) but typically is managed by Javascript for clients that have it (most standard web browsers) then you're golden.
EDIT:
Per OP question in a comment about parallel paths.. Say I have a link, an anchor tag.
<a id="moxune_services" href="http://moxune.com/services" action="get" target="_self">Moxune Services</a>
You can see that this is a valid link (and I will be getting SEO points for it from StackOverflow ;P But anyway, say this is part of a heave JS driven site, and rather than refreshing the whole page when this link is clicked, I just want to have a subsection of the page like where a div w/ id="content" is present be replaced by the fresh content after I have AJAX load it. The js would be something like this (w/o testing, this is just off the top of my head) (a jQuery solution as well):
// very crude jQuery example!
$('#moxune_services').click(function() {
$.get($(this).attr('href'), function(sNewHtml) {
$('#content').replaceWith(sNewHtml);
});
});
Now you see, the google bot can reach the page through the HTML a tag, no problem, but your customers looking for a Web 2.0 (TM) website will be able to enjoy the lack of full page refreshes as they have JS enabled (and hopefully aren't using IE 6 :O).
One term for this is 'graceful degradation'.
quickshiftin is right here. There's no point hiding the index.php
If you must, however do this:
RewriteRule ^index\.php.+$ / [L,R=301]
I didn't test this, so it might not work, but the general idea is to redirect index.php to /