Home Rewrite URL (folder name to custom URL with folder name as variable value) in .htaccess
Reply: 0

Rewrite URL (folder name to custom URL with folder name as variable value) in .htaccess

user7378
1#
user7378 Published in September 19, 2018, 3:18 am

I'm using these two lines to rewrite any URL like www.example.com/spyke (where spyke is a username, can be any username)..

RewriteCond %{REQUEST_URI} ^/([^/]+)? [NC]

RewriteRule ^/([^/]+)? http://www.example.com/index.php?id=82&user=$1 [L,R=301]

This ALMOST works, but the URL the system currently is redirected to is:

www.example.com/index.php?id=82&user=index.php

.. instead of

www.mydomain.com/index.php?id=82&user=spyke

1) So I want to rewrite www.mydomain.com/spyke to www.example.com/index.php?id=82&user=spyke .. Does anybody know how to achive this?

2) Also, I would like the user to see www.example.com/spyke in the address bar instead of www.example.com/index.php?id=82&user=spyke - is this possible as well?

Thanks!!!!!

Roel

Here's my (updated) htaccess file btw:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule ^/typo3$ - [L]
RewriteRule ^/typo3/.*$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* /index.php


RewriteRule ^/([a-zA-Z0-9_-]+)? http://www.example.com/index.php?id=82&user=$1 [L,R=301]


</IfModule>

..

But this just results in this link: http://www.example.com/index.php?id=82&user=index

share|improve this question
  • 1
    How will a user be translated to id? – anubhava Oct 30 '14 at 8:42
  • 1
    id is always 82; it's "user" that needs to be variable – R_K Oct 30 '14 at 9:02

2 Answers 2

active oldest votes
up vote 2 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.29196 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO