htaccess help needed, Please?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

htaccess help needed, Please?

Postby BigDC » 25. March 2015 05:08

0 down vote favorite


I am trying to use htaccess file to rewrite urls, I really have zero experience at this and everything I have done is from searching here and on google. My links have query parameters in them. I send everything to an index.php page.

I have tested all the links before trying to rewrite them and they all work in the index page. So then I created an htaccess file to rewrite the links but all I get is a blank page, none of the variables are being sent to the index page. I use $_GET in the index.php page to retrieve the variables.

Here is a list of type of links I am trying to rewrite along with a copy of my actual htaccess file, also mod rewrte is on and functioning properly in apache. Please help me change my htaccess file to do EXACTLY what I am wanting according to the sample links I have shown below, please?

The directory rewrite is fine and works accordingly, it is the links that don't.

Also, if you notice in links #1 and #2 the page parameter does not and should not appear in the rewritten links for these 2 links ONLY, but a blank or empty string is still sent to my index.php.

example--

Code: Select all
<?php

$page= $_GET['page'];
$user= $_GET['user'];
$act= $_GET['act'];
$section= $_GET['section'];
$search= $_GET['search']
$xx= $_GET['xx'];

if($page == ''){
   //Do some code
}elseif($page == 'search'){
   //Do some code
?>



Rewrite these type of links

LINK #1

http://localhost/notetag2/johnsmith/all/1

--REWRITE TO--

http://localhost/notetag2/index.php?page=&user=johnsmith&act=all&section=1


-------


LINK #2

http://localhost/notetag2/johnsmith/all

--REWRITE TO--

http://localhost/notetag2/index.php?page=&user=johnsmith&act=all


-------


LINK #3

http://localhost/notetag2/search/johnsmith

--REWRITE TO--

http://localhost/notetag2/index.php?page=seach&search=johnsmith


-------


LINK #4

http://localhost/notetag2/pictures/1

--REWRITE TO--

http://localhost/notetag2/index.php?page=pictures&xx=1


-------


Rewrite directory

pages

--REWRITE TO--

web


-------



HERE IS MY ACTUAL HTACCESS FILE

Code: Select all
<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteBase /notetag2/
    RewriteRule ^index\.php$ - [L]

    RewriteRule ^(.*)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ notetag2/index.php?page=$1&user=$2&act=$3&section=$4 [L,NC]

    RewriteRule ^(.*)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ notetag2/index.php?page=$1&user=$2&act=$3 [L,NC]

    RewriteRule ^(.*)/([a-zA-Z0-9_-]+)/?$ notetag2/index.php?page=$1&user=$2 [L,NC]

    RewriteRule ^(.*)/$ notetag2/index.php?page=$1 [L,NC]

    RewriteRule ^search/([a-zA-Z0-9_-]+)/?$ notetag2/index.php?page=search&q=$1 [L,NC]

    RewriteRule ^pictures/([a-zA-Z0-9_-]+)/?$ notetag2/index.php?page=picturesh&xx=$1 [L,NC]

    RewriteRule ^([a-zA-Z0-9_-]+)/?$ $1.php [L,NC]


    RewriteRule ^pages/(.*) web/$1 [L]


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* /notetag2/index.php [L,QSA]

</IfModule>

BigDC
 
Posts: 1
Joined: 25. March 2015 04:53
Operating System: Windows 8.1

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 41 guests