Member Avatar

Dear All, This must be a very common problem, but yet nowhere on the internet wishes to display a working answer. I am in a sticky situation. I have the following .htaccess file on my local webserver: http://localhost/testsite/.htaccess DirectoryIndex home.php?view=home RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ home.php?view=$1 [QSA,L] ErrorDocument 404 /home.php?view=404 I now upload this file to http://domain.com/.htaccess and it simply will not work (404 errors). The URLs are meant to work like this: http://domain.com/gallery transforms server side to http://domain.com/home.php?view=gallery Please could someone suggest where my code may be going wrong and why? …

Member Avatar
+0 forum 1
Member Avatar

hello im a little new to htaccess specially mod_rewrite, i know mod_rewrite allows us to rewrite request. Can anyone write me the exact code how to rewrite my path to files?. Before my files(jc,css,images..etc.) reside in example /images/image.png, but now it has a parent directory folder named "public" so my path now is /public/images/image.png. how can i rewrite it? i hope some will help me so i don't have to do the hard way and add all paths to /public.

Member Avatar
+0 forum 1
Member Avatar

I have a problem with one of my php scripts. I've got a file called view.php. If I go to test.com/view?id=7575 it comes up with a 404 error. However if I go to test.com/view.php?id=7575 it works. Why is this?

Member Avatar
+0 forum 3
Member Avatar

Hi all, I am running through the book "PHP Advanced and Object Oriented Programming" by Larry Ullman and I am currently trying to use a mod_rewrite to change my GETs to look like standard URLs. I am running the site on my localhost. My .htaccess file is being read (tested by putting garbage in to generate an error) but it isn't making the changes to the URL. The .htaccess is as follows: <IfModule mod_rewrite.c> # Turn on the engine: RewriteEngine on # Set the base to this directory: RewriteBase /Modular_Website/ # Redirect certain paths to index.php: RewriteRule ^(about|contact|this|that|search)/?$ index.php?p=$1 </IfModule> …

Member Avatar
+0 forum 1
Member Avatar

Hi all, I'm having some issues with RewriteRules conflicting in my .htacccess file. For starters, here's the file: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On #Start forum rules RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] #Start wiki rules RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L] RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B] </IfModule> I'm running a forum (IPBoard) and a wiki (Mediawiki) and both have basically the same goals. The forum uses friendly URLs by removing index.php …

Member Avatar
+0 forum 1
Member Avatar

This .htaccess throws me a 500 error. I've Googled/tried everything. RewriteEngine on RewriteRule ^([0-9]{6})$ decode.php?shorturl=$1 [L] It's for a URL shortener. I am new to this stuff.

Member Avatar
+0 forum 9
Member Avatar

Hi Everyone. I have a htaccess file the re-writes my urls for a directory on a website I am helping to develop for a friend. the directory structure is mydomain.co.uk/dir1/dir2/shopping-cart/ The mod_rewrite rule rewrites the index.php file into pretty urls for example: shopping-cart/123/this-is-the-item-title The problem I am facing is when we try and use the same htaccess for the mobile side we get the internal server error. The directory structure is the same for the mobile as it is for the desktop Any help would be appreciated as we have been digging around for a few days now. Here is …

Member Avatar
+0 forum 7
Member Avatar

Hi Guyz, Am facing an issue that $_GET[] not working in my Mod_Rewrite, My Odd URL is : http://groupon.ig-demo.com/index.php?id=12&dealname=Oil%20Treatment My Friendly URL is : http://groupon.ig-demo.com/id/12/Oil%20Treatment.htm And My HTACCESS is : Options +FollowSymlinks DirectoryIndex index.php RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] RewriteRule ^id/([^/]*)/([^/]*)\.htm$ /index.php?id=$1&dealname=$2 [QSA,L] When i try this all are working fine but $_GET["id"] and $_GET["deal_name"] is not working for me, $_GET[] attribute is not working, Any help much appreciated! Thank You.

Member Avatar
+0 forum 4
Member Avatar

I Need Help With My **.htaccess** file .. Now i have link like that http://www.afrogfx.com/20121028050853/Test.html problem located with **Slash /** !! if you click on my link you will found link without style if remove slash you will get 404 Not Found Like That http://www.afrogfx.com/20121028050853Test.html Try it !! **Here Is my .htaccess** RewriteEngine On RewriteRule ^([a-zA-Z0-9-/]+).html$ readmore.php?url=$1 RewriteRule ^([a-zA-Z0-9-/]+).html/$ readmore.php?url=$1 **readmore.php** <?php include ('config/connect_to_mysql.php'); $url=$_GET['url']; if($_GET['url']) { $url=mysql_real_escape_string($_GET['url']); $url=$url.'.html'; //Friendly URL $sql=mysql_query("select * from posts where url='$url'"); $count=mysql_num_rows($sql); $row=mysql_fetch_array($sql); $title=$row['title']; $text=$row['text']; } else { echo '404 Page.'; } ?> **Problem Here** <?php include('styles/header.php'); include ('styles/leftblock.php'); include ('styles/mrnuleft.php'); ?> <?php if($count) …

Member Avatar
+0 forum 1
Member Avatar

I have used following mod_rewrite rules: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %(REQUEST_FILENAME) !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] to get **www.myweb.com/newyork** from **www.myweb.com/index.php?url=newyork.** Now I trying to get pretty url for this page www.myweb.com/itemdetail?itemid=1000 to www.myweb.com/itemdetail/1000 I have been trying several mod_rewrite rules, but I have not been able solve it. Following are few rules I tried but no success. #RewriteCond %{QUERY_STRING} ^itemid=([A-Za-z0-9]+) #RewriteRule ^itemdetail.php /itemdetail/%1? [R=301,L] #RewriteRule ^itemid/([A-Za-z0-9]+)/?$ itemdetail.php?itemid=$1 [L] #RewriteRule ^itemdetail/([0-9]+)/?$ itemdetail.php?itemid=$1 [NC,L] #RewriteRule ^itemdetail/([0-9]+)/$ itemdetail.php?itemid=$1 [NC,L] Any suggestion?

Member Avatar
+0 forum 1
Member Avatar

I'm using a code snippet from the Invision Power Board forum software on my own site to, sort of, connect the two. I have a "member bar" that I wanna put on every page in my website that has a login link, profile link, etc. I've already done this, the only problem is that on the pages I want to implement it on, I have to put a ? after the ".php". So I need a mod_rewrite condition that turns `http://www.mysite.com/index.php` into `http://www.mysite.com/index.php?` `http://www.mysite.com/html/about.php` into `http://www.mysite.com/html/about.php?` I know this is probably very simple, but I've tried to learn regular expressions …

Member Avatar
+0 forum 3
Member Avatar

My question requires a little background first: I'm working on a Web project where there are four theatres owned by a single company, so not only will the four theatres each need their own Website (each with its own unique branding), but the umbrella company will need one as well. I realize that one solution is to have 5 different domains pointing to 5 different Websites on 5 different servers with 5 different MySQL databases. But since all 5 Websites will share a lot of the same content, this solution is highly inefficient, not to mention costly. I realize that …

Member Avatar
+0 forum 2
Member Avatar

I am trying to give each MOVIE there own url name, for example, [url]www.helloworld.com/BATMAN[/url]. I have been using mod_rewrite to create such url. I have been using following htaccess code to achieve such result. RewriteEngine ON RewriteCond %(REQUEST_FILENAME) !-d RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] The mod_rewrite works perfectly. When A user enters randam movie name (name that does not exist in database), for example, [url]www.helloworld.com/abcd[/url], I have created a url redirect which is [url]www.helloworld.com/oopsmovienotfound.php[/url]. This works fine too. But the problem I am having is this: When user click [url]www.helloworld.com/login.php[/url] .The url keeps looping between …

Member Avatar
+0 forum 6
Member Avatar

Hello, I want to make a simple website, and friendly urls would be a great step towards that. I have been trying this for 2 days without success. [url]www.mydomain.com/join[/url] redirects to [url]www.mydomain.com/index.php?path1=join[/url] [url]www.mydomain.com/forum[/url] redirects to [url]www.mydomain.com/index.php?path1=forum[/url] [url]www.mydomain.com/forum/getting-started[/url] redirects to [url]www.mydomain.com/index.php?path1=forum&path2=getting-started[/url] These directories do not actually exist. They are going to look like they do. You should understand what I'm trying to achieve now. index.php [CODE] <?php global $path1; global $path2; $path1=""; $path2=""; if (isset($_GET['path1'])) { $path1=$_GET['path1']; } if (isset($_GET['path2'])) { $path2=$_GET['path2']; } //code omitted. Standard XHTML header if (isset($path1)) { switch ($path1) { case "join": include("join.php"); break; case "forum": include("forum-index.php"); …

+0 forum 0
Member Avatar

This is the first time I have ever tried to use mod_rewrite and have been stuck for a couple days. I am trying to change [url]www.mysite.com/example6.php?id=games[/url] to [url]www.mysite.com/example6/games[/url] Is this even achievable? Any advice will be very much appreciated!

Member Avatar
+0 forum 5
Member Avatar

On my site when a link is clicked, the adress bar in the browser shows this URL: [CODE] http://www.enkelt-webdesign.dk/index.php?sid=1&titel=FORSIDE [/CODE] I would lke the URL to appear like this: [B][url]http://www.enkelt-webdesign.dk/Forside[/url][/B] I have this code in my .htacess file which is not working as it is: [CODE] <ifModule mod_rewrite.c> RewriteEngine on #Regler til index.php RewriteRule ^Forside$ index.php?sid=1&titel=FORSIDE </ifModule> [/CODE] [B]THIS IS ACTUALLY WORKING, WHEN THIS LINKED IS FOLLOWED - BUT THEN WHEN I CLICK ON THE LINK AFTER I HAVE ARRIVED TO THE PAGE, THEN I GET THE UGLY URL WITH THE QUERY STRING AGAIN. HOW CAN I KEEP THE PRETTIER …

Member Avatar
+0 forum 15
Member Avatar

hello friends, i trying to change the extension .php into .html in my local server but it still shows the .php extension. i have test.php and after the mod_rewrite it just show the test.php but if i type in url test.html then it also show the same content of test.php, that i want but i don't want to type test.html in the url, i want it automatically change if i call the file test.php the .htaccess code is here [ICODE] Options +FollowSymLinks RewriteEngine On RewriteBase /tests RewriteRule ^/?test\.html$ test.php [L] [/ICODE] pls help to solve this prob.

Member Avatar
+0 forum 2
Member Avatar

Hi all, I am posting this thread to learn a bit of how mod_rewrite works. I want to specificly learn to make dynamic urls from websites, become seo friendly: [B]MADE UP LINK, DONT FOLLOW[/B] [url]www.sitename.php/index.php?sid=2&pid=231[/url] [B]MADE UP LINK, DONT FOLLOW[/B] look like: [url]www.sitename/furnitures/sofas[/url] And learn how to prevent duplicate content etc etc. If someone knows of a good book, (I know theres many) I would be happy to get some info. Or good online tuts maybe. Klemme

Member Avatar
+0 forum 1
Member Avatar

Is there a way to write a line in .htaccess so that a rewrite rule will NOT rewrite the URL if a certain query_string is found or if a certain page is referring to the page about to be rewritten?

+0 forum 0
Member Avatar

Ahhhh! OK, so I've been learning PHP for about 7 years now on and off, but never have I taken the time to look into URL rewriting. Until now I've not needed it, but you can guarantee the one thing you think you wont need, you need! I have the following URL style: [url]www.sitename.com/profile.php?user=username[/url] Of which I would like rewriting to: [url]www.sitename.com/username[/url] (Preferred) OR [url]www.sitename.com/user/username[/url] I also need it to be reversible, so if someone types in [url]www.sitename.com/username[/url] it works. Any ideas? Previous attempt was setting up mod_rewrite rules in .htaccess, is this the best way? If not, how? Any …

Member Avatar
+0 forum 8
Member Avatar

Does anyone know about cleaning up URLs for CMS? I had a .htaccess file containing the following code (or so far as I can remember) [CODE] RewriteEngine On RewriteRule ^([a-z])$ /index.php?url=$1 [L] RewriteRule ^/article/([a-z])$ /index.php?url=$1&type=news [L] [/CODE] which was working fine ie: [url]www.mysite.com/somepage[/url] loaded the "mypage" content into my index.php file ([url]www.mysite.com/index.php?url=mypage[/url]) However, when adding content, I came across a situation where the url was containing both numbers and letters, which of course won't work with this pattern. I changed the [a-z] bit to a wildcard, which returned a 500 error, so I changed it back again and just get …

Member Avatar
+0 forum 5
Member Avatar

I'm working on generating SEO friendly URLs from data taken from a database. I've been successful for the most part. The only issue I'm having is when I stripped the spaces and made them dashes, I lose the data being pulled from the database. If I leave the spaces in there (ex. [url]www.test.com/test/this[/url] is a sample article/) it works fine. When I replace the spaces with dashes I lose the data that supposed to be displayed on the page. It also works if I change the spaces to '+' signs. I'd like to have '-' or '_' though. Query code: …

Member Avatar
+0 forum 2
Member Avatar

Hello, i have a question about mod_rewrite. I have the following url: [url]www.example.com/listen.php?title=U2_with_or_without_you&youtube_video_id=hTgnDLWeeaM[/url] Now, i want to rewrite it like this: www.example.com/U2_with_or_without_you->hTgnDLWeeaM Now, my question is, since i can't use the caracters - or _ as separators between the get parameters, it is "safe" to use -> ? Is it standard? I don't want to interfere with other websites, if the link will be bookmarked on facebook, or added as link in a youtube description, or anything else... What do you say?

Member Avatar
+0 forum 6
Member Avatar

I am on a godaddy server now and trying this mod-rewrite stuff and it is still not working. I have been searching google now for hours looking for the answer and cannot find it. Here is my entire .htaccess file: #Rewrite Rules Options -MultiViews Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)(/?)$ index.php?p=$1 [L] #RewriteEngine On #RewriteBase / #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteCond %{REQUEST_FILENAME}.php -f #RewriteRule ^(.+)$ /$1.php [L,QSA] #RewriteRule ^c/([^/.]+)/?$ index.php?p=$1 [L] The stuff thats commented out is what I tried the first time, then I tried …

Member Avatar
+0 forum 2
Member Avatar

Hello. I've set up pagination for my results. I do this with a class. I also have pretty urls with mod_rewrite. I'm wondering how to echo the urls for the paginated data. Currently I have this below for the links. [CODE]$links .= ' ' . $prefix . '<a href="' . $this->php_self . '?' . $this->append . '&page=' . $i . '">' . $i . '</a>' . $suffix . ' ';[/CODE] This echos out a link like so [CODE]/index.php?menu=tags&tag=action&page=2[/CODE] My mod_rewrite works and looks like this [CODE]/tags/action/page/2[/CODE] Question is.. How do I change the url in my first code to work …

Member Avatar
+0 forum 1
Member Avatar

SO I am trying to setup a RewriteRule on my server for caching static objects. the files are in this naming scheme /docroot/css/stylesheet.min.css and I have them printed in the code like /docroot/css/stylesheet.min.123438348.css (the number is example it comes from a get modified function). Note docroot is an example directory how can I have the server ignore the numbers and redirect to the stylesheet.min.css I need to do this for every css and js files (/js and /css) as well as one specific spritemap image my current attempt [CODE]RewriteRule ^/(docroot)/(js|css)/(.+).(min).(.+).(js|css)$ /$1/$2/$3.$4.$6 RewriteRule ^(/docroot/images/spritemap).([0-9]+).(png)$ $1.$3[/CODE] Update: Now I have the setup …

Member Avatar
+0 forum 1
Member Avatar

Ive read a few tutorials to try and get this mod_rewrite to work but have no luck. I have checked my phpinfo and everything should work. I am trying to change this url: [url]http://domain.com/viewAlbum.php?aid=2[/url] (any number) to this url: [url]http://domain.com/album/2/[/url] Here is my .htaccess file and I dont know if I have this set up correct. [CODE]Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule ^album/([0-9]+)/$ viewAlbum.php?aid=$1 [NC,L] RewriteRule ^(\w+)$ http://domain.com/viewAlbum.php?aid=$1[/CODE] I copied the last line of code from another thread on here. Any suggestions would be awesome! Thanks, Brian

Member Avatar
+0 forum 14
Member Avatar

Hi, I was looking into SEO friendtly urls and how to get it set up . I found some solutions to do with mod_rewrite . If the usual URL is [url]http://website.com?category_id=10&post_id=10[/url] And i want the url like [url]http://www.website.com/category[/url] name/ post title / how do i do this ? ive seen in some website where only part of the post title comes in the url .. Please suggest options .. Thanks

+0 forum 0
Member Avatar

This script works perfect it forces the trailing slash and hides the .php extension BUT! it does not redirect people going directly to the .php extension. How can I also force people going directly to the file.php to /file/ [CODE] RewriteEngine On RewriteRule ^(.*)/$ /$1.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.)/$ RewriteRule ^(.)$ http://www.mysite.com/$1/ [R=301,L] [/CODE]

Member Avatar
+0 forum 2
Member Avatar

Hi all, I have a site that has a dynamically generated page and looks like this: [url]www.example.com/articles.php?aid=1[/url] [url]www.example.com/articles.php?aid=2[/url] [url]www.example.com/articles.php?aid=3[/url] The page has the article title and description stored in a database and printed in the page itself. How do I go about changing the URL from this: [url]www.example.com/articles.php?aid=1[/url] To this: [url]www.example.com/articles/how-to-fix-a-laptop[/url] where the article description is stored in a database? Thanks in advance. Max.

Member Avatar
+0 forum 4

The End.