Hi, is there a way to make pretty url's without using hte apache rewrite mod. instead of www.yourdomain.com/site.php?mid=1345&uid=341 i want www.yourdomain.com/site/1345/341 Thanks, Michael
You can use PHP only if it is in this format: www.yourdomain.com?site/1345/341 You need the question mark, otherwise it is not possible unless you use mod rewrite.
You can do this : www.yourdomain.com/site/mid/1345/uid/341 if you want ? http://www.tutorio.com/tutorial/php-alternative-to-mod-rewrite-for-se-friendly-urls
In apache, this is done in rewrite url/mod.. I don't see any reason why you shouldn't use it unless you don't have apache in your server - though some http server offers some kind of url redirection
Last time I checked, it doesn't work that way - that still uses rewrite url.. Maybe you seen it to other websites and thought it will work without rewrite?
No, I actually tried it. Joomla for instance has an option to do that if there isn't mod_rewrite available. After that you must parse the parameters using $_SERVER['PATH_INFO']
I've wondered this too. There must be a way to do this without mod_rewrite. Otherwise how are the clean url extensions for vBulletin and SMF ect doing it?
I was hopeing to find a way without apache rewrite so the script can be ran on different webservers without any issues.
I would suggest you create a sub domain for your URL. You can you other URL shortening services too, but the sub domain is the best in my opinion.
Here's the complete rewrite rule for you: www.yourdomain.com/site.php?mid=1345&uid=341. For this, you need to have apache mod_rewrite enabled. Let me know if you have problems in the rewrite rule. RewriteEngine On RewriteRule ^(.*)/(.*)[^\/]$ site.php?mid=$1&uid=$2 [L] Code (markup):
As above this is the only way, if mod_rewrite is not enabled, although the url may not look so pretty, its adequate enough for SEF urls , don't let the part about creating a .htaccess file confuse you, its nothing to do with mod_rewrite. Some scripts have an option to enable mod_rewrite if its available on the hosts server, so perhaps you could do that and incorporate the above if its not, there's today very few servers that don't run apache so its really not that big of an issue and besides, some have an alternative to mod_rewrite.
IMHO you shouldn't worry about it. Pretty URLs aren't as important as you think. Great example is DP which doesn't use them.
ndevendra, Thanks for that. That gives me a starting place. I will be needing at least 4 urls to rewrite for the one site, so how could I tell them apart in the reWriteRules? urls would be like http://www.domain.com/site.php?id=1234&par=abc-123 http://www.domain.net/site/234/abc-123 http://www.domain.com/spinner.php?id=321&par=abczz http://www.domain.com/spinner/321/abczz http://www.domain.com/banner.php?id=111&par=abc153 http://www.domain.com/banner/111/abc153 http://www.domain.com/banner/111.jpg The par is optional Thanks, Michael
From the example you will still write in the top section of the appropriate file: $data[0] = whatever var is been use in this file $data[1] = whatever var is been use in this file $data[2] = etc... $data[3] = PHP: and then your .htaccess file will contain <FilesMatch "^site$"> < ForceType application/x-httpd-php > </FilesMatch> <FilesMatch "^spinner$"> < ForceType application/x-httpd-php > </FilesMatch> <FilesMatch "^banner$"> < ForceType application/x-httpd-php > </FilesMatch> PHP: So those file names can be phrased without having to use the .php extension. I guess in each of the files you will have a simple " if check mod_enabled, 1 or 0 to use this or run with mod_rewrite. Some kind of database check against or to read a config file looking for a setting yes or no etc...
i would say it is very much possible without apache rewrite module. Wordpress uses a unique technique where rewrite rules is stored in database rather than in .htaccess files. as far as i know wordpress doesnt need mod-rewrite to be enabled for pretty links. May be we can learn something from wordpress. http://corpocrat.com/2009/12/22/where-does-wordpress-store-htaccess-rewrite-rules/ http://codex.wordpress.org/Using_Permalinks