Good morning,
I am building a new website and i would like to make the urls SEO friendly.
The folder structure is as follow:
/index.php <-- first page
/frame.php <-- page wrapper which includes all the modules
/modules <-- All the modules
/modules/en/module-name/index.php
/modules/en/module-name/page2.php
/modules/en/module-name/page3.php
/modules/en/module-name-2/index.php
...
How can i make a .htaccess mod rewrite that allows me to visit the next urls to go to the pages above, and keep the structure the same for new urls?
So i would like to go to:
http://www.url.com/en/module-name/ === http://www.url.com/frame.php?page=en/module-name/index.php
or
http://www.url.com/en/module-name/page3 === http://www.url.com/frame.php?page=en/module-name/page3.php
etc
I have multiple domain LTD's so i prefer to not include the domain name
Is this possible?
Thanks for everyones help!
If you want to make your urls SEO friendly (and also don't want your urls to look like they come from the 2000s) you could use NGINX. Maybe this will help:
Rewrite all requests to index.php with nginx
Related
After I have upgraded my site I see that once I go live with new version some parts of the website URLs will not be redirected for gallery, blogs and files because of new structure. And there is no way fixing it within the CMS. So my goal is to use NGINX redirects.
I wonder do any of you know any NGINX rewrite tricks to make such redirects possible?
website.com/forums/blogs/ into website.com/blogs/
website.com/forums/gallery/ into website.com/gallery/
website.com/forums/files/ into website.com/files/
I actually need the part forums dropped from the URL only and ONLY when the address is going for forums+blogs/gallery/files. Don't want to loose that google traffic.
So for example
website.com/forums/blogs/entry123/my-dog/ is redirected to
website.com/blogs/entry123/my-dog/
BUT
website.com/forums/topic/my-dog/
is left alone and working just like before because the following subfolder is neither blogs or gallery or files.
I needed that once on Apache and this one worked but on Nginx I have no idea.
RewriteRule ^forums/(blogs|gallery|files)/(.*)$ /$1/$2 [L,R=301]
You can try something like
rewrite ^/forums/(blogs|gallery|files)/(.*)$ /$1/$2;
Please note that rewrite directive accepts some flags wich meaning depends on where is it placed (is it inside a server or location block). Detailed documentation is here.
I would like to add a line to my htaccess to change this url:
RewriteEngine on
do this is the url
http://site/Calendar/viewevent?eventid=9223
into something like this :
http://site/Calendar/viewevent/Title-of-event
its php and joomla and I am a php developer, please dont advise me to use a component or module to handle redirects, I am trying to achieve this using .htaccess ONLY :) thank you in advance!!
Your 'pretty' url contains information that is not in the 'working' url. Besides that, the 'working' url also contains information that is not in the pretty url. You need database access to translate the event id to a seo-title, and the seo-title back to an event id. In other words: It is impossible to do this with .htaccess only, unless you change 'viewevent' to accept an event by seo-title, instead of eventid.
Mod_dbd can possible be used, but only in the server config file, not .htaccess.
As Sumurai8 says htaccess cant transform url like you want automatically.
But you can use Redirect 301 (or its variation) for one url to another.
for your example:
Redirect 301 /Calendar/viewevent?eventid=9223 /Calendar/viewevent/Title-of-event
more information here
I have just been asked to migrate a site from one server to another for a site that I did not build. They have a lot of links to pages that dont exist.
<a href="app/batteries">
This is not actually a directory in the site, but there is an app.php file in the root directory. I have gotten it to display the products by redirecting anything to the app/ directory to app.php?app=. The value of ?app= is dynamic, so any solution would need to be dynamic. I have simply used the redirect statement in the htaccess file to get it to the app.php page. Is there a way to get the url back to the pretty url after a redirect?
Any help would be awesome. Thanks in advance.
You should use ModRewrite instead, for matching a pretty url with regexps, and converting into the url using the app.php.
The rewrite is local to the server, so the visitor sees only pretty urls.
I want to rewrite pagination URLs http://mydomain.com/category?start=15 to http://mydomain.com/category/start/15, but I don't know how to achieve this with .htaccess.
PS: those URls ( http://mydomain.com/category?start=15) are referenced in search engines so I need to add 301 redirect to my new URLs.
I want mention that I already enabled SEF mode in Jommla configuration
First, if you want your URLs to look like /start/15 you have to rewrite them from the pretty format to the internal, not otherwise.
I currently have no access to an Apache, but your expression should look something simliar to this:
RewriteRule ^category/start/([0-9]+)$ http://mydomain.com/category?start=$1 [QSA,L]
Then, it would be neccesary to tell Joomla how to generate the pretty URLs, this happens without the htaccess file, for example in a SEO plugin.
Finally, to output 301 messages, you will want to add "Redirect" commands to your .htaccess file. Redirect incoming ?start=15 URLs to the pretty format. Make sure that this does not happen after your Rewrite...
I want to rename a folder on my site from http://mywebsite.com/myfolder/ to http://mywebsite.com/mynewfolder/. The urls for the old folder name are all index by Google and may other sites have linked to mine. What is the correct way to ensure that visitors coming to the site on the old folder name will now see the new folder name? Should I chane the name of the folder on my server and then use mod_rewrite to force the new url (folder name)
this seems to work, but is it correct: Redirect 301 /myfolder /mynewfolder
also for SEO would it be better to use: /my-folder-name/
RewriteEngine on
RewriteRule ^oldfolder/ /newfolder/ [R=301,NC]
It is widely acknowledged that hyphenating (-) your URLs makes a small impact on SEO as it separates any keywords in your URL rather than having them read as one long string. However saying that I'm pretty sure Google is clever enough to have a go at working this out for themselves. I don't suppose it would hurt and it makes it easier for your user to read at the very least.