I am developing a php web site. Here I want to make the site as clean URL.
My index page is domain/news/index.php?i=1. I want to display this URL as clean URL. But I am the beginner of URL rewriting. Does anyone help me??? How to write this URL
Thanks in advance
You need to add an .htaccess file into your root and define the rewriting things there. This is not "in PHP" because PHP doesn't provide a url rewriting method. It's the server (Apache) that read url rewriting files such as .htaccess.
References
Url Rewriting Guide
You can take either of two approaches. The first is to make correct rewrite URL for all links in .htaccess, and the second is to redirect all links with .htaccess to index and "possess on it" with PHP.
Rewriting is easy and there are many relevant docs to be found on the web. Please search first.
Related
Long time I am trying to define Rewriting rules but I could not succeed yet? I have a simple page http://www.myURL.com/pdf.php?id=2. I want to make it friendly by this: http://www.myURL.com/pdf/2/ ...
I wrote this rule after spending time on google:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^pdf/([0-9]+)\$ pdf.php?id=$1.
When I uploaded my .htaccess file on server and try to run first it give me 500 ERROR. Second time it loaded page but it could not show me friendly URL; it was showing as before.
Kindly tell me better solution, I followed many instructions to make it useful but could not successful. My Client are not going further unless I showed him friendly URL. kindly help me as soon as possible. This is my client hosting Organization: Justhost.com.
You can do this using Apache's Rewrite Engine. Something like this:
RewriteEngine On
RewriteRule ^pdf/([0-9/]+)$ /pdf.php?id=$1 [L]
This will allow you to go to http://yoursite.com/pdf/192 instead of http://yoursite.com/pdf.php?id=192
Here is a very simple tutorial on using Apache's mod_rewrite to create friendly URLs.
Probably a bit too much to take just right now but you could look at some of the available MVC frameworks to help you solve this. I'm guessing that the host only offers PHP 5.2 so I'd take a look at the routing/controller solution from Zend Framework 1.12 to solve this as that can be implemented into existing code without too much trouble.
I am trying to implement URL rewriting in my PHP application. Can someone share a step by step procedure of implementing URL rewriting in PHP
In my application I want to implement following URL rewriting
http://example.com/fast-five
http://example.com/300
http://example.com/13-b
from
http://example.com/movie-download.php?nm=fast-five
http://example.com/movie-download.php?nm=300
http://example.com/movie-download.php?nm=13-b
One more thing which URL will be best according to SEO, management, application point-of-view out of the following two types.
Of course
http://example.com/fast-five
will be good for SEO
Are you serving your PHP through an Apache HTTP Server installation? If so:
RewriteRule ^/fast-five$ /movie-download.php?nm=fast-five [R=301]
From an SEO perspective, the first would be preferred. Using the HTTP 301 ("Moved Permanently") is most effective for this.
If your using an MVC framework like CakePHP, you should look at the documentation on routing. Otherwise, you can use the web servers rewriting rules.
I created a website using php, passing values from page to page either with POST or GET.
Though there is some cons, I dont know how to track specifically what data has been viewed in GoogleAnalytics as it just shows the name of the page (xxxx.php)
On the other side, I see websites structured differently with a bunch of subdirectories created : www.xxx.com/xxxxxx/xxxxx/xxx
This looks like pretty manual for me , compared to the .php?xxxx=xxxx way of structuring.
Do you know how this subdirectory style structuring can be automatically obtained?
This is done with Apache rewrite rules.
To make it so that whenever a user goes to /posts/visiting_new_york, it actually goes to to /viewpost.php?id=visiting_new_york, you create a file in your site called .htaccess like this:
RewriteEngine On
RewriteRule '^posts/([^/]+)$' viewpost.php?id=$1 [L]
Use an MVC framework like rails, or simply configure your webserver's virtual directory structure to be identical to the local servers file system and adhere to that scheme when saving your php files.
Yes, you can do this with "mod_rewrite" in apache.
It involves creating a .htaccess file with URL re-writing rules inside.
So you can transform /index.php?page=contact&lang=en into /en/contact/
Here's a good rewrite cheat sheet: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
Wadih
You need to read about url rewriting
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
If you just want to track your dynamic pages , there is another solution in Google analytic
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55504
Say if you visit my site: http://nesmods.com/page/2/ there isn't actually a /page/2/ on my site, Wordpress somehow catches the URL and generates a page based on the URL. What is the name of this technique?
This redirecting is managed by the mod_rewrite Module of Apache. Normally this is done in the .htaccess file. Depending on the configuration of your FTP program you can see them as hidden files in the Wordpress root directory.
Some further explanations and examples: http://www.workingwith.me.uk/articles/scripting/mod_rewrite - and Google of course.
Clean URLs apparently. Often done through .htaccess files.
There are a few ways to do this, referred to as URL routing or URL rewriting. Wordpress uses URL routing to map URL structures to it's internal functions that generate content.
It can also be done with the web server itself, such as URL Rewriting with Apache mod_rewrite
Apache hava a module of rewrite url。
It is a good search engine optimization。
This is a detail info about rewrite http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
I started a blog and when I changed my permalink structure to /%postname%/ I get a Page Not Found error. I want my url to look like this:
http://bobbybeckner.com/sharepoint-list-and-linq-using-jquery-and-ihttphandler/
not this:
http://bobbybeckner.com/index.php/sharepoint-list-and-linq-using-jquery-and-ihttphandler/
I read a few posts about changing .htaccess but found no clear solution. Any code examples welcome or recommendations on wordpress plug-ins would be greatly appreciated.
Update
I thought it would be important to mention that my host is running IIS7 but does not allow users to touch it. In addition, I'm uncertain of any restrictions on the .htaccess file or any other configuration limitations.
.htaccess files only apply to Apache (well, maybe some other servers use it too, but not IIS). AFAIK URL rewriting for IIS is possible, but not as easy.
ISAPIRewrite appears to be a commercial application that does this, but of course, you'd need to get it installed on your server.
Personally, I wouldn't lose any sleep over having /index.php/ in your urls.
Generally when you fill out the structure, if the .htaccess file is writable it will apply the rewrite for you, and if it isn't it will show what the contents should be at the very bottom of the page. Did you check the bottom of the page if it is not writable?
You do NOT have to code this yourself.