Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 04:49

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

Advertisement



htaccess url kürzen get

Discussion on htaccess url kürzen get within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Cc_Cc_Cc's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 421
Received Thanks: 17
htaccess url kürzen get

Hallo,

ich weiß es gibt etliche Beispiele wie man eine url kürzen kann aber ich habe soviele ausprobiert und verstehe es warum es bei mir nicht funktioniert?

Ganz simples beispiel:

Ich will meine URL von



zu



machen.

Was ist an dem Code falsch?


Fehlermeldung:

Cc_Cc_Cc is offline  
Old 02/16/2021, 03:01   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
Quote:
Originally Posted by Cc_Cc_Cc View Post
Hallo,

ich weiß es gibt etliche Beispiele wie man eine url kürzen kann aber ich habe soviele ausprobiert und verstehe es warum es bei mir nicht funktioniert?

Ganz simples beispiel:

Ich will meine URL von



zu



machen.

Was ist an dem Code falsch?


Fehlermeldung:

It should be something like this:


Btw if your planning to make MVC pattern your rewrite rule should look sth like this:

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
QSA handles query strings or sth im not an expert in php


Edit:
Rewrite rule for removing index.php?page={anything} and replacing with /{anything}
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule . %1? [L,R]

#RewriteRule . index.php [L]
elmarcia is offline  
Thanks
1 User
Old 02/16/2021, 05:19   #3
 
Cc_Cc_Cc's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 421
Received Thanks: 17
Quote:
Originally Posted by elmarcia View Post
It should be something like this:


Btw if your planning to make MVC pattern your rewrite rule should look sth like this:

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
QSA handles query strings or sth im not an expert in php


Edit:
Rewrite rule for removing index.php?page={anything} and replacing with /{anything}
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule . %1? [L,R]

#RewriteRule . index.php [L]
thanks it works but I get this error again:
Not Found
The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

my files are in the folder pages and my index file is on this folder: /
Cc_Cc_Cc is offline  
Old 02/16/2021, 18:40   #4
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
Quote:
Originally Posted by Cc_Cc_Cc View Post
thanks it works but I get this error again:
Not Found
The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

my files are in the folder pages and my index file is on this folder: /

Code:
RewriteEngine On
RewriteBase /

# Prevent looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

# Rewrite if not index.php page
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

# Change url from page={something} to {something} and redirect
RewriteCond %{REQUEST_URI} /index.php
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule . %1? [L,R]
This will work but, you cannot pass query string in index.php other than page.

localhost/home -> will be interpreted as index.php?page=home
localhost/index.php?page=home -> will redirect to -> localhost/home
elmarcia is offline  
Thanks
1 User
Old 02/16/2021, 20:01   #5
 
Cc_Cc_Cc's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 421
Received Thanks: 17
Quote:
Originally Posted by elmarcia View Post
Code:
RewriteEngine On
RewriteBase /

# Prevent looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

# Rewrite if not index.php page
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

# Change url from page={something} to {something} and redirect
RewriteCond %{REQUEST_URI} /index.php
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule . %1? [L,R]
This will work but, you cannot pass query string in index.php other than page.

localhost/home -> will be interpreted as index.php?page=home
localhost/index.php?page=home -> will redirect to -> localhost/home
thank you it works, but now my homepage has no CSS style. Because the htaccess redirects the css style to index.php
Cc_Cc_Cc is offline  
Old 02/17/2021, 16:08   #6
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
Quote:
Originally Posted by Cc_Cc_Cc View Post
thank you it works, but now my homepage has no CSS style. Because the htaccess redirects the css style to index.php
Sorry forgot to add these lines:

RewriteEngine On
RewriteBase /

# Prevent looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

# Rewrite if not index.php page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

# Change url from page={something} to {something} and redirect
RewriteCond %{REQUEST_URI} /index.php
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule . %1? [L,R]
elmarcia is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Buying] htaccess Profi für "Affiliate Links, per htaccess Maskieren"
12/20/2017 - Coders Trading - 1 Replies
Ich suche einen htaccess Profi der sich gut bis sehr gut mit Regular Expressions/RedirectPermanent auskennt. Es ist am Ende nicht wirklich viel Arbeit. Wer sich wirklich damit auskennt, wird keine 30min dafür brauchen. Allerdings zahle ich keinen 50€ Stundenlohn, dass sage ich auch gleich. Um sich ein Bild von der Aufgabe machen zu können https://www.elitepvpers.com/forum/web-development /4406582-affiliate-links-per-htaccess-maskieren.ht ml
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?
mod_rewrite hilfe - URL kürzen
01/04/2013 - Web Development - 4 Replies
Hallo, ich habe hier ein CMS was Automatisch die Links erstellt, wenn ich eine neue Seite erstelle. In meinem Fall hier habe ich eine Seite mit Regeln stehen. Daer link wird von dem CMS wie folgt erstellt: Domain.de Ich möchte jetzt aber noch zusätzlich wenn man http://www.domain.de/regeln im Browser eingibt, dass man auf Domain.de geleitet wird. Versucht habe ich es wie folgt:



All times are GMT +1. The time now is 04:50.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

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