apache rewrite rule?

I have a url that looks like this:

https://domain.de/artikel/article.php?artikel=eintext

I would rather use the URL as

https://domain.de/artikel/eintext

in the browser so I have to rewrite it from https://domain.de/artikel/eintext to the old internal one I think, what then has to be put into my .htaccess to

to remove?

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
3 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
JulianOnFire
1 year ago

So if you have the URL https://domain.de/artikel/eintext internal to https://domain.de/artikel/article.php?artikel=eintext want to convert, you can do this with the following rules in your .htaccess file:

RewriteEngine On

# Rewriting of ‘https://domain.de/artikel/eintexthttps://domain.de/artikel/article.php?artikel=eintext

RewriteRule ^artikel/([^/]+)/?$ artikel/article.php?artikel=$1 [L,QSA]

  1. RewriteEngine On

switches on the transfer module.

With the rule

^artikel/([^/]+)/?$

check URLs that start with “/artikel/” and then have any text that does not contain any other Slash (/).

With

([^/]+)

start the text after “artikel/”. This value then becomes

$1

used.

[L,QSAL] sind Optionen:

L means that no further rules are then checked.

  • QSA adds the original Query string if there is one.
Babelfish
1 year ago
Reply to  Mensch4

The target should start with a slash:

RewriteRule ^artikel/([^/]+)/?$ /artikel/article.php?artikel=$1 [L,QSA]