Score:-1

I'm in trouble with .htaccess RewriteRule

im flag

I'm trying make to a social platform like Instagram or Facebook and I wanna to show users, username like that examplesite.com/usernamehere so in the url. I'd been researching how to do this and I learned it's made with htaccess rewrite codes. I have a code

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ user.php?url=$1 [QSA,L]

Its working generally but for example when i want to enter to examplesite.com/login or register page, rewriterules thinks the word login or register is a username and it never opens. The folders must be open and also css, scss, js, img etc. folders on my server must be taken as a username, so if anyone examplesite.com/css, img or js etc. words write to url, should not be opened css, img or js files.

Sorry about my english. Thank everyone! <3

Score:2
la flag

A number of different things:

Don’t use .htaccess files

There are numerous well-intended examples of code in .htaccess files that then get copied again and again by/for cargo cult system administrators that should be reading the actual manual instead.

From: https://httpd.apache.org/docs/2.4/howto/htaccess.html

In general, you should only use .htaccess files when you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in .htaccess files, and, in more recent years, another misconception that mod_rewrite directives must go in .htaccess files. This is simply not the case.
...
In the case of RewriteRule directives, in .htaccess context these regular expressions must be re-compiled with every request to the directory, whereas in main server configuration context they are compiled once and cached. Additionally, the rules themselves are more complicated, as one must work around the restrictions that come with per-directory context and mod_rewrite. Consult the Rewrite Guide for more detail on this subject.

Second:

You mentioned a couple of directory names already that should be excluded from the example.com/[user-alias] mapping.

Don’t forget to also prohibit people from intentionally selecting those directory (and other) names as their user-alias as well in your sign up page.

Last

RewriteCond directives are used to restrict the types of requests that will be subject to the following RewriteRule.

Your config currently says, in "plain" English, don’t apply the following RewriteRule when there is an existing file or directory with the same name as the file name component from the request.

You simply can add extra conditionals to that with extra RewriteCond lines, for example:

RewriteCond %{REQUEST_FILENAME} !"login"

should exclude example.com/login

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.