Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.