How to show HTML website URLs like wordpress [duplicate] - url

This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 8 years ago.
I'm creating a website for my personal needs. I have different pages like index.html, about.html, contact.html etc...
The default way of showing them is mysite.com/index.html or mysite.com/contact.html
But is there any way to hide the extension part .html and just to show the url main texts like mysite.com/about/ or mysite.com/contact/ ??
Please advice me.

You have to use a URL rewrite engine, edit (or create) the .htaccess like that:
# Remove .html from url
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
For more details: Remove .html from URLs with a redirect

It's possible to show your page with mysite.com/about/
You need to replace all file name to index.html
Eg : about.html to index.html
Add index.html to their respective pages, like
Before:
www/
|
|-about/about.html
|
|-contact/contact.html
|
|-etc/etc.html
After :
www/
|
|-about/index.html
|
|-contact/index.html
|
|-etc/index.html
Now when you hit the URL www.yourSite.com/about that page will be shown. (without about.html part)

Related

mod rewrite url automatically

I have a problem for rewrite this url:
http://example.org/public/item.php?id=4
i id like to rewrite with htaccess file in:
http://example.org/public/item/4.php
this is my htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /public
RedirectMatch ^/$ /public/
RewriteRule ^public/item/([^/]*)\.php$ /public/item.php?id=$1 [L]
that works only if i digit manually the previous url, but i lost all the style css, javascript file, and images, also i want to do this redirect seo url automatically.
what I'm doing wrong?
You have to add a condition if the requested filename(javascript, css, image, etc. files) actually exist not to rewrite the url,
So all you have to do is to add a condition before your rewrite rule:
RewriteCond %{REQUEST_FILENAME} -f
check here the Documentation

mod_rewrite to insert directory in dynamic URLs?

I am looking for a way to write a mod_rewrite in order to insert a directory into an URL? I want to redirect old URLs to new URLs like so:
old URL: http://www.domain.com/viewtopic.php?f=1&t=128468
new URL: http://www.domain.com/forum/viewtopic.php?f=1&t=128468
I would like this to work for all values of 'f' and 't'. Thanks!
This works:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !/forum/
RewriteCond %{REQUEST_URI} /viewtopic
RewriteRule ^viewtopic\.php$ /forum/viewtopic\.php [L,R=301]
</IfModule>
The first line checks that /forum/ is NOT already present in the URI.
The second line checks that /viewtopic is present in the URI.
the third line replaces viewtopic.php with /forum/viewtopic.php

how to convert static urls from dynamic urls?

Can you please help me this?
i have classified site: 99clix.in/latest/ , Actually it is under construction. it creates dynamic dynamics urls, i want to convert into seo friendly urls.
Eg:
DYnamic Url: http://www.99clix.in/latest/index.php?welcome/category/Mobile-Phones/Mobile-phones
Static Url:
http://www.99clix.in/latest/Mobile-Phones/Mobile-phones.
Same way i need to create for all categories and subcategory as per user search.
can you help me out for this?
Write below code in .htaccess file in your root directory, this will allow you allow you to access url without index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please provide little more detail about your application so we can provide more personalized solution -- are you using any framework etc..

Redirect 301 for Active Forum

thanks for reading, pls help out if u can :)
if i want to redirect the entire forum.jalan2.com to subfolder, whats the best way to do it ?
So its on jalan2.com/forum/
How to make EVERY PAGE redirect correctly when accessed from the google ?
Say this page :
forum.jalan2.com/topic/9689-mimiland-batu-payung-village-singkawang-bengkayang/
So it becomes
jalan2.com/forum/topic/9689-mimiland-batu-payung-village-singkawang-bengkayang/
I dont want thousands of the old pages to redirect to only 1 page which is forum home at jalan2.com/forum/
i want each page redirect exactly to the new page location
Thanks :)
Rudy
Add this to your .htaccess in your web root / directory of forum.jalan2.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.jalan2.com$ [NC]
RewriteRule ^(.*)$ http://jalan2.com/forum/%{REQUEST_URI} [R=301,NC,L,QSA]

Rewriting my BASE URL - Vbulletin

I currently have a vbulletin forums that I coppied the theme of to another site to make an application.
with this at the top of the files:
<base href="http://example.com/forums/"/><!--[if IE]></base><![endif]-->
So I simply copied/pasted the source code then modified the body.
The problem here is I have a "submit.php" button and what it does it goes based upon the base url so it becomes http://example.com/forums/submit.php but I want it to do this instead:
http://application.example.com/submit.php
If I change the BASEURL from the source code the theme won't work anymore and I'm trying to preserve the theme
If you use apache with mod_rewrite, you can create the .htaccess file in the root directory
RewriteEngine on
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Only apply to URLs that aren't already under folder forums.
RewriteCond %{REQUEST_URI} !^/forums/
# Rewrite all those to insert /forums.
RewriteRule ^(.*)$ /forums/$1
Documentation
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Resources