Jump to content

RewriteRule like Twitter


Terminator1995

Recommended Posts

Hi,

first I'm sorry if I posting this in wrong forum - and sorry for my bad english.

 

I want to make RewriteRules like Twitter - So that the files are displayed as Virtual folders, but if you add the file extensions (.php) he shouldn't view this file!

 

 .htaccess edit:

AddDefaultCharset UTF-8
    Options +FollowSymlinks
    Options -Indexes
    Options -ExecCGI
    <FilesMatch "^\." >
    deny from all
    </FilesMatch>

    RewriteEngine on
    RewriteBase /

    RewriteCond %{SERVER_PORT} !=443
    RewriteRule ^(.*)$ https://www.abc.com/ [R=301,L]

    RewriteRule ^profil/$ profil.php?ID=$1 [NC,L]

    RewriteRule ^([^.]+)/([^.]+)/$ $2.php?ID=1 [NC,L]

Can anyone help me??

 

Best regards

Termi

Link to comment
https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/
Share on other sites

When talking about URL rewriting you need to say precisely what URLs are you looking to be "virtual folders" and how should they map to PHP scripts.

 

The "profil" (are you sure you don't want "profile"?) one is missing the part where it captures the ID in the URL. Presumably that's a number?

RewriteRule ^profil/(\d+)$ profil.php?ID=$1 [L]
The second one is very generic. What is it supposed to be used for? It should be more specific than simply "anything slash anything".

 

Also, avoid [NC] when possible. URLs should be case-sensitive, or at the very least redirect to a particular cased version.

1. ) Yes the name "Profil" is correct, it's the german name of profile ;-)

2. ) Yes the ID is a number.

3. ) OK i updated my htaccess, with your hints (Thanks for that)!

 

But my question was (if you add the file extensions (.php) he shouldn't view this file!), have you an answer for that.

 

Best regards

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.