Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 13:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



.htaccess rewrite

Discussion on .htaccess rewrite within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1

 
Mr.Tr33's Avatar
 
elite*gold: 2778
Join Date: Feb 2012
Posts: 3,527
Received Thanks: 1,044
.htaccess rewrite

Moin,

mir kam vorhin ein Gedanke, ich weiß aber nicht ob dieser überhaupt in der Art überhaupt umsetzbar ist

Erst einmal habe ich folgenden Code:
Code:
RewriteEngine on 
RewriteRule \. - [L]
RewriteRule ^([^/]+)/?$ index.php?$1 [L,NC]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?$1=$2 [L,NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?$1=$2&$3 [L,NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?$1=$2&$3=$4 [L,NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?$1=$2&$3=$4&$5 [L,NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?$1=$2&$3=$4&$5=$6 [L,NC]
Damit muss ich aber für bei $_GET die Variable und den Wert setzen, damit es die nächste Variable erkennt.

Gibt es eine Möglichkeit den Wert zu überspringen?
So würde es ohne der .htaccess aussehen:
Quote:
p3&p4=a4
Und so mit:
Quote:
p3/p4/a4
Wenn nicht, würde es dann gehen, wenn ein bestimmtes Zeichen bei der Variable (hier p3) drangehangen wird, dass es den Wert dann überspringt? Also so z.B.
Quote:
p3~/p4/a4
MfG,
Mr.Tr33
Mr.Tr33 is offline  
Old 07/23/2014, 01:14   #2
 
KoKsPfLaNzE's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 731
Received Thanks: 233
wieso machst du das so komplex? leite doch einfach alle anfragen bei dennen die datei nicht vorhanden sind an die index.php weiter und definier dir routen in php da kannst das um einiges besser steuern, meiner meinung. zumindest laeuft das bei allen groeßeren sachen so
KoKsPfLaNzE is offline  
Old 07/23/2014, 15:20   #3
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
You are trying to hard, keep the first parameter and simply explode the url.
turk55 is offline  
Old 07/23/2014, 17:12   #4

 
Mr.Tr33's Avatar
 
elite*gold: 2778
Join Date: Feb 2012
Posts: 3,527
Received Thanks: 1,044
Quote:
Originally Posted by KoKsPfLaNzE View Post
wieso machst du das so komplex? leite doch einfach alle anfragen bei dennen die datei nicht vorhanden sind an die index.php weiter und definier dir routen in php da kannst das um einiges besser steuern, meiner meinung. zumindest laeuft das bei allen groeßeren sachen so
Verstehe ich nicht so ganz, wie meinst du das?
Beispiele wären klasse
Quote:
Originally Posted by turk55 View Post
You are trying to hard, keep the first parameter and simply explode the url.
I don't get what you're trying to explain. How about a few examples?
Mr.Tr33 is offline  
Old 07/23/2014, 19:24   #5
 
KoKsPfLaNzE's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 731
Received Thanks: 233
alles an die index weiterleiten, wenn es die datei net gibt un wenn es kein style, js oder ein bildchen ist.
PHP Code:
RewriteEngine On

RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_URI} !(\.css|\.js|\.jpg|\.png|\.gif)$ [NC]
RewriteRule ^.*$ index.php [NC,L
danach kommst ja an die url im php un kannst die dann auf verschiedene routen checken, damit steuerst dann deine controller un die actions an.
KoKsPfLaNzE is offline  
Old 07/23/2014, 20:06   #6

 
Mr.Tr33's Avatar
 
elite*gold: 2778
Join Date: Feb 2012
Posts: 3,527
Received Thanks: 1,044
Das wollte ich doch gar nicht.
Ich will mein Link nur anders anzeigen lassen, sodass ich nicht immer ein value bei $_GET brauche sondern auch hin und wieder nur ein key (oben eig. gut genug erklärt, es kamen ja keine Verständnisfragen).
Mr.Tr33 is offline  
Old 07/25/2014, 15:30   #7
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
Quote:
Originally Posted by Mr.Tr33 View Post
I don't get what you're trying to explain. How about a few examples?
Let's say the url is "website.com/index.php?page=news/15/test" without the htaccess rewrite rule, otherwise "website.com/news/15/test" but nevermind that.

So a simple explode will look like this:
$url = explode("/", $_GET["page"]);

$url is an array now where it splitted the string "news/15/test" using the slash (/) as delimiter
the value of $url[0] is news
the value of $url[1] is 15
the value of $url[2] is test

Oh and you should check always check those parameters for dots (.) and slashes (/). Otherwise hackers might end up using an RFI Injection.
turk55 is offline  
Old 07/25/2014, 19:56   #8

 
Mr.Tr33's Avatar
 
elite*gold: 2778
Join Date: Feb 2012
Posts: 3,527
Received Thanks: 1,044
That's not what I want >.>

I want to tell the URL a GET with a key and a value but sometimes I don't have a value so I want to ignore the value part.

Example:
website.com/index.php?key=value&key2=value2&key3&key4=value4
website.com/key/value/key2/value2/key3/key4/value4
key3 has no value and with my code (in the first post) "key4" would be the value for value3

My question is, how can I say that key3 has no value so that I can jump over the value3?
Mr.Tr33 is offline  
Old 07/25/2014, 20:24   #9

 
elite*gold: 0
Join Date: May 2014
Posts: 91
Received Thanks: 28
Insert any character and ask for it in your php script, I don't really understand the problem.
マルセル is offline  
Reply


Similar Threads Similar Threads
[HELP] Mod rewrite on CMS by Hen!
04/04/2014 - Metin2 Private Server - 2 Replies
Hi! Whether it is possible to shorten links to such a form /register from index.php?s=register in CMS by Henn! ? Oh, I forgot, how can I insert recaptcha(from google) to register or any other site? Thanks!
Mod Rewrite Hilfe
03/13/2014 - Web Development - 4 Replies
Hey, Brauche mal kurze Hilfe. Habe derzeit folgende URL : blablabla.de/?blabla=123 will gerne das ich aber über blablabla.de/123
Mod Rewrite Problem
09/09/2013 - Web Development - 3 Replies
Hallo Elitepvpler! Und zwar habe ich ein Problem. Ich habe einen Signaturen Generator. Die Links spuckt er mir so aus: klick Mit meiner .htaccess sollte es dann aber so gehen: http://134.255.216.192/1/2.png Hier meine .htaccess: RewriteEngine OnRewriteRule ^(*)/(*)\.png$ /signature.php?id=$1&signature=$2
htaccess URL Rewrite
04/17/2013 - Web Development - 4 Replies
Hallo, Kenne mich mit htacess URL Rewrite nicht wirklich aus, daher Frage ich hier nach. Also folgendes: Punkt 1) Wenn eine Person die Datei z.B /install/install.php aufruft wie sieht der htaccess Code dafür aus das er nur /install/ sieht? Punkt 2) Wenn jemand die URL username.game.domain.tld aufruft wie ist es Möglich das diese dann auf /profile/username.php weiterleitet?
Old SREmu ReWrite - Working
01/19/2009 - SRO Hacks, Bots, Cheats & Exploits - 116 Replies
Step 1 - Install Visual Basic 6 Step 2 - Go to http://svn.darkinc.net/srvb/ and download all the files to your computer username is user and theres no password. or just download this one (Rev 45) but it might be updated because cls is constantly re coding it all. RapidShare: 1-Click Webhosting Step 3 - Locate to C:\Windows\System32\drivers\etc and add the following lines to your hosts file. - 127.0.0.1 gwgt1.joymax.com - 127.0.0.1 gwgt2.joymax.com Step 4 - Download the cracked...



All times are GMT +1. The time now is 13:02.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.