I just implemented Pretty URL taken from this question: htaccess question .
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=302]
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
RewriteCond %{THE_REQUEST} \s/*(.*?)/index\.php [NC]
RewriteRule ^ %1/ [R=302,L]
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^.]*?[^/.]$ %{REQUEST_URI}/ [L,R=302]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+?)/?$ $1.php [L]
But it broke my site in several places. On pages that are not index.php, I had to add a full link, for example <script src="https://www.example.com/js/bootstrap.min.js"></script>, and not only <script src="/js/bootstrap.min.js"></script>, is this the best fix for this?
In my AJAX code
$.fn.login_user = function () {
var email = $('#login_email').val(),
password = $('#login_password').val(),
remember_me = $('input:checkbox:checked').val();
alert("test: " + email + " " + password);
$.ajax({
type: 'POST',
url: '../php/login.php',
data: {email: email, password: password, remember_me: remember_me},
success: function (response) {
alert(response);
}
});
};
jQuery- , , , , . AJAX , .htaccess .php /, . javascript, , .
:
mysite.com - index.php
- communications.php
/php/ all php files here
/js/ all js and jquery files here
/css/ all css files here