Jump to content

Htaccess And $_Get


unlishema.wolf

Recommended Posts

I am working on writing a htaccess file to "hide" my $_GET fields. However I am only able to do 1 field and sometimes I have multiple (Examples below). I do not know the santex of htaccess hardly at all.

 

Current urls I can have:

http://unlishema.us.to
http://unlishema.us.to/?p=projects
http://unlishema.us.to/?p=projects&p2=minecraft
http://unlishema.us.to/?p=forum
http://unlishema.us.to/?p=forum&c=1
http://unlishema.us.to/?p=forum&c=1&t=2

 

 

My current rewrite rule is as follows:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ http://unlishema.us.to/?p=$1 [L]
</IfModule>

 

I need someone with knowledge of htaccess to help me make a rewrite rule that can work with all these urls.

Link to comment
https://forums.phpfreaks.com/topic/272571-htaccess-and-_get/
Share on other sites

What I would like to do is the following. Sorry for not including in the first post:

http://unlishema.us.to
http://unlishema.us.to/projects
http://unlishema.us.to/projects/minecraft
http://unlishema.us.to/forum
http://unlishema.us.to/forum/1
http://unlishema.us.to/forum/1/2

 

I don't have to worry about the forum's as far as indicating 1 is c and not p2. The only code I have that gets p2 is in my main index. The fourm index has completely separate code. I just need to modify my url so it gives me the info but it looks like a directory not $GET values.

Link to comment
https://forums.phpfreaks.com/topic/272571-htaccess-and-_get/#findComment-1402550
Share on other sites

Also I have been working on trying to get this to work off and on. I have got http://unlishema.us.to/news to redirct to http://unsliehma.us.to/?p=news and it works. However, when i try to redirect http://unlishema.us.to/projects/minecraft it redirects fine but it then tries to load my style from http://unlishema.us.to/projects/styles/default/style.css along with my images and everything. Here is my code so you can see the exact problem. You can also see my live site at http://unlishema.us.to but just FYI the nav links are for the old index.php not the new one.

 

.htaccess

<Files .htaccess>
order allow,deny
deny from all
</Files>
Options -Indexes


RewriteEngine on
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?p=$1&c=$2&t=$3 [L]
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?p=$1&c=$2 [L]
RewriteRule ^([a-z0-9\-]+)$ index.php?p=$1 [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?unlishema.us.to/.*$ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [NC,R,L]

ErrorDocument 400 http://unlishema.us.to/?error
ErrorDocument 401 http://unlishema.us.to/?error
ErrorDocument 403 http://unlishema.us.to/?error
ErrorDocument 404 http://unlishema.us.to/?error
ErrorDocument 500 http://unlishema.us.to/?error

 

index.php

<?php
$Page_Name="Projects";
$style="default";
$href="./";
$u_agent = $_SERVER['HTTP_USER_AGENT'];


$page="main";

if(isset($_GET['p']))
$page=$_GET['p'];

if($page == "projects") {
if(isset($_GET['c']))
 $project = $_GET['c'];


if(!isset($project))
 include $href."project/default.php";
else
 include $href."project/other.php";
} else if($page == "gallery") {
 include $href."gallery.php";
} else if($page == "forum")) {
 include $href."forum.php";
} else {
 $type=$page;
 include $href."default.php";
}


include $href."styles/$style/footer.php";
?>

Link to comment
https://forums.phpfreaks.com/topic/272571-htaccess-and-_get/#findComment-1402565
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.